我是以编程方式将共享文件添加到基于所有者的文件夹,但是当我这样做时,它会更改Modified By用户和Modified Date。有没有办法将它添加到文件夹而不更改文件数据?
if (type == "A"){//add to "A" Folder
destA_folder.addFile(file);
}else{ //add to B Folder
destB_folder.addFile(file);
}
答案 0 :(得分:1)
您可以使用Drive API v3来实现它。使用DriveApp和Drive API v2添加文件夹时,将更新“修改者”用户和“修改日期”。但是在Drive API v3中,这些都没有更新。此示例脚本使用{API} v3的update
。
var fileId = "### file ID ###"; // Please input file ID.
var orgFolder = DriveApp.getFileById(fileId).getParents().next().getId();
if (type == "A"){//add to "A" Folder
var dstFolderA = '### destination folder ID ###'; // Please input destination folder ID.
var url = "https://www.googleapis.com/drive/v3/files/" + fileId + "?addParents=" + dstFolderA + "&removeParents=" + orgFolder;
}else{ //add to B Folder
var dstFolderB = '### destination folder ID ###'; // Please input destination folder ID.
var url = "https://www.googleapis.com/drive/v3/files/" + fileId + "?addParents=" + dstFolderB + "&removeParents=" + orgFolder;
}
var params = {
method: "patch",
headers: {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
muteHttpExceptions: true,
};
var res = UrlFetchApp.fetch(url, params);
Logger.log(res)
"&removeParents=" + orgFolder
。如果这不是你想要的,我很抱歉。