0
我无法在NodeJs应用程序中重命名Google Drive中的文件。我正在使用:无法使用nodeJs库重命名Google Drive文件
- googleapi nodeJs library v。
20.1.0
。 - 节点诉
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
:resumable
,multipart
和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 {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.
所以我在想,我是不是做错了什么,这是预期的,这意味着我们不能编辑文件名,还是在图书馆的错误?
差不多!原来它必须通过'params.resource = {name:“newname”}'来设置。我必须补充说,这个文档对此很模糊......如果你能更新答案,我会接受它:-) – ghego1
同意文档是可怕的。我认为这些库是自动生成的,或者至少对所有Google服务都是通用的,因此通常缺乏文档和行为 – pinoyyid