google-apps-script - 如何在不更改 File1 的 ID 的情况下将版本从 File1 更新到 File2?
问题描述
这个问题我想了好久还是没能解决,所以特地来请教了。
我正在创建一个基于谷歌脚本的应用程序。我在 Google Drive 中存储了 2 个 PDF 文件:File1 和 File2。
我想通过 File2 更新 File1 的版本而不更改 File1 的 ID。
是否可以使用 Google Script Drive API v2 做到这一点?
解决方案
您可以在 Google Apps 脚本项目中启用 Advanced Drive API 服务,然后使用此代码段更新 Google Drive 中现有文件的内容。
Drive.Files.update(
{
title: "file 1.pdf",
mimeType: "application/pdf"
},
"id of file 1",
DriveApp.getFileById("id of file 2").getBlob()
)
推荐阅读
- python-3.x - 问题链接上的 Jira Python Keyerror
- image - 如何在 CLI 中按图像大小顺序列出 Google Container Registry 中已发布的容器图像
- angular - 使用不同的 client_id 多次调用 gapi.auth2.init
- ios - 触摸事件不会在部分扩展到父 UIView 之外的子 UIView 之外注册
- laravel - 如何通过匹配键及其值来组合两个集合
- angular - 使用 Angular Elements 构建微前端
- java - 在 Spring Boot 中将 JSON 文件作为 JSONArray 返回
- php - 如何通过php中的正则表达式查找PDO查询中的参数?
- java - Java Vigenere 密码
- javascript - 现有示例中 Mapbox gl 上的过滤器