2017-07-16 13 views
0

NodeJsアプリでGoogleドライブのファイルの名前を変更できません。私は以下を使用しています:Googleドライブのファイル名をnodeJsライブラリの名前に変更できません

  • googleapi nodeJs library v。20.1.0
  • ノードv。8.1.4

アプリは細かいファイルの要求を処理している、そしてファイルを複製することができます。ただし、それらを更新すると、新しいnameは決して適用されません。

ファイルリソースには、私はthe request was successfulを伴うファイルリソースがあります。

私はこれをやっている:

const google = require('googleapis'); 
let googleService = google.drive('v3'); 

let params = { 
    auth: testedAndValidOAuth, 
    fileId: validFileId, 
    uploadType: 'multipart', 
    name: "some name 2" 
}; 

googleService.files.update(params, (err, response) => console.log(response)); 

私は、すべての利用可能なオプションで、で、それなしで試してみたプロパティuploadTypeについて:resumablemultipart、およびmediaを。 mediaをしようとすると、私は次のエラーました:私は手動でライブラリ内のリンクを編集しようとした

Error: The API returned an error: Error: Uploads must be sent to the upload URL. Re-send this request to https://www.googleapis.com/upload/drive/v3/files/xxxfileIdxxx?uploadType=media&name=some+name+2 

を、エラーが去っていきましたが、残念ながら名前は変更されませんでした。図書館で探し

私はname paramは言及されていないことに気付きました:

@param {object} params Parameters for request 
@param {string=} params.addParents A comma-separated list of parent IDs to add. 
@param {string} params.fileId The ID of the file. 
@param {boolean=} params.keepRevisionForever Whether to set the 'keepForever' field in the new head revision. This is only applicable to files with binary content in Drive. 
@param {string=} params.ocrLanguage A language hint for OCR processing during image import (ISO 639-1 code). 
@param {string=} params.removeParents A comma-separated list of parent IDs to remove. 
@param {boolean=} params.supportsTeamDrives Whether the requesting application supports Team Drives. 
@param {boolean=} params.useContentAsIndexableText Whether to use the uploaded content as indexable text. 
@param {object} params.resource Media resource metadata 
@param {object} params.media Media object 
@param {string} params.media.mimeType Media mime-type 
@param {string|object} params.media.body Media body contents 
@param {object} [options] Optionally override request options, such as `url`, `method`, and `encoding`. 
@param {callback} callback The callback that handles the response. 

は、だから、私は何か間違ったことをやって、思ったんだけど、これは我々が編集できないことを意味し、意図されますファイル名、またはライブラリのバグですか?

答えて

0

はほとんどコメント

+0

あたりのように補正

params.resource = {name: "newname"} 

例えば、params.media.bodyに新しい名前を設定してみてください!それは 'params.resource = {name:" newname "}'によって設定されなければなりません。私はこの文書がかなり不明瞭であると付け加えなければなりません...あなたが答えを更新できるなら、私はそれを受け入れます:-) – ghego1

+0

は文書がひどいと同意します。私はライブラリが自動生成されているとか、少なくともすべてのGoogleサービスに共通のものだと思うので、ドキュメントや動作に欠けていることが多い – pinoyyid

関連する問題