如何在不更改文件的 Google ID 的情况下使用 googledrive::drive_upload()?
How to use googledrive::drive_upload() without changing the Google ID of file?
当我将 pptx 文件上传到云端硬盘(或任何文件)时,我想维护该文件的 Google ID,但每次我执行此功能时,一个新的 Google即使在 overwrite=TRUE
时也会创建 ID。这会破坏利益相关者用来在云端硬盘中查找文件的超链接。有没有办法在上传期间覆盖时保持 Google ID?
googldrive::drive_upload(
my_pres,
name = "My Presentation",
type = 'presentation', # converts pptx to Googleslides
overwrite = TRUE
)
根据驱动器 API 的文档 googledrive::drive_upload() wraps the Files.create 方法。这是用于更新 文件的错误函数。 overwrite
参数设置为 TRUE 代表:
"[...] Check for a pre-existing file at the filepath. If there is zero or one, move a pre-existing file to the trash[...]"
您应该使用驱动器 API 的 googledrive::drive_update() which wraps the Files.update 方法。从 R 文档中,描述为:
"[...] Update an existing Drive file id with new content ("media" in Drive API-speak), new metadata, or both. To create a new file or update existing, depending on whether the Drive file already exists, see drive_put(). [...]"
当我将 pptx 文件上传到云端硬盘(或任何文件)时,我想维护该文件的 Google ID,但每次我执行此功能时,一个新的 Google即使在 overwrite=TRUE
时也会创建 ID。这会破坏利益相关者用来在云端硬盘中查找文件的超链接。有没有办法在上传期间覆盖时保持 Google ID?
googldrive::drive_upload(
my_pres,
name = "My Presentation",
type = 'presentation', # converts pptx to Googleslides
overwrite = TRUE
)
根据驱动器 API 的文档 googledrive::drive_upload() wraps the Files.create 方法。这是用于更新 文件的错误函数。 overwrite
参数设置为 TRUE 代表:
"[...] Check for a pre-existing file at the filepath. If there is zero or one, move a pre-existing file to the trash[...]"
您应该使用驱动器 API 的 googledrive::drive_update() which wraps the Files.update 方法。从 R 文档中,描述为:
"[...] Update an existing Drive file id with new content ("media" in Drive API-speak), new metadata, or both. To create a new file or update existing, depending on whether the Drive file already exists, see drive_put(). [...]"