从服务帐户上传的文件的 Google Drive API 所有权 [英] Google Drive API ownership of files uploaded from service account

查看:18
本文介绍了从服务帐户上传的文件的 Google Drive API 所有权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用服务帐户从服务器上传文件,但它已达到其存储配额限制.所有文件都已添加到另一个用户(具有 100 Gb 存储配额的 @gmail.com 帐户)创建的文件夹下,但上传的所有文件都归服务帐户所有.

We are using a service account to upload files from a server and it has reached its storage quota limit. All files had been added under a folder created by another user (a @gmail.com account with 100 Gb storage quota) but all files uploaded are owned by the service account.

请注意,我们没有真正的用户,我们只是将 Google 驱动器用于存储目的.

Note that we don't have real users, we are only using Google drive for storage purposes.

目前我们无法使用服务帐号上传更多文件.

At the moment we are not able to upload any more files using the service account.

有没有办法

  • 将服务帐户拥有的所有文件的所有权转移到具有 100 Gb 存储配额的 @gmail.com 帐户
  • 使用服务帐号上传文件,但让文件归上传文件所在文件夹的所有者所有
  • 将@gmail.com 帐户用作服务帐户

谢谢

推荐答案

要转移文件的所有权,您可以依赖 Permissions 资源中的insert"方法.您将需要 fileId 作为必需参数,并使用以下属性填写请求正文:角色:[所有者],类型:[用户],以及这些 id:[驱动器内的用户 ID] 或值:[电子邮件之一来自云端硬盘帐户].您可以在此链接中找到更多信息:https://developers.google.com/驱动器/v2/参考/权限/插入

To transfer the ownership of the file, you can rely on the "insert" method from the Permissions resource. You will need the fileId as a required parameter, and fill out the request body with the properties for: Role: [owner], Type: [user], and either one of these id:[userId within drive] or value:[email from the Drive account]. You can find more information in this link: https://developers.google.com/drive/v2/reference/permissions/insert

这篇关于从服务帐户上传的文件的 Google Drive API 所有权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆