【发布时间】:2021-01-23 12:41:33
【问题描述】:
我目前使用 Google Cloud 的 GWT 应用程序存在问题。
我实际上有一段代码可以让您使用 google drive 应用程序上传文件。 除了这里,随着谷歌的更新,谷歌驱动器上的文件不再可能有多个父母,我们可以在这里看到:
" 您只能为还没有父项的项目添加父项。这会影响 children.insert (v2)、files.update (v2 / v3) 和 parents.insert (v2) 端点。您可以使用新的 canAddMyDriveParent 功能来检查项目当前是否没有父项,以及用户是否有足够的权限为该项目添加父项。"
所以我有以下代码:
service.files().update(fileId, file).execute();
产生错误:
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "Increasing the number of parents is not allowed",
"reason" : "cannotAddParent"
} ],
"message" : "Increasing the number of parents is not allowed"
}
但我不知道如何上传文件,而不会出现此错误。
事实上,我不知道如何创建一个新的父文件夹,或者我是否可以在没有父文件夹的情况下上传。 如果有人可以帮助我,任何帮助将不胜感激!
非常感谢!
【问题讨论】:
-
什么文件?您只能添加一位家长。
-
我只能将 1 个文件添加到 1 个父级?或者我只能为我的文件设置 1 个父级?编辑:当我这样做时:service.files().list() 它打印:{} 但是,当我打印我的文件时,我有很多信息,比如“父母”:[{“id”:“anyId”,“isRoot” :true,"kind":"drive#parentReference","parentLink":"googleapis.com/drive/v2/files/…"},{"id":"anyId2"}]
-
谷歌驱动器只是文件存储系统。一个文件只能有一个父目录,或者它会位于两个不同的位置。可以将父级设置为多个文件的父级,这意味着它有多个子级。父母是单数。
-
@DaImTo 我怎样才能创建一个新的父母?或者在其他地方更新我的文件?
-
您需要创建一个新文件夹。 developers.google.com/drive/api/v3/folder
标签: google-app-engine google-cloud-platform gwt google-drive-api