亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

使用 Google Drive API 變更透過帳戶服務(wù)建立的文件的擁有者
P粉680487967
P粉680487967 2024-01-06 11:03:37
0
1
770

我使用服務(wù)帳戶將文件上傳到 Google 雲(yún)端硬碟中的共用資料夾。

一段時(shí)間後,我發(fā)現(xiàn)服務(wù)帳戶擁有的檔案消耗了服務(wù)帳戶的磁碟機(jī)儲存(我的錯(cuò)),現(xiàn)在我已經(jīng)用完了服務(wù)帳戶的磁碟機(jī)空間。

我已經(jīng)將網(wǎng)域範(fàn)圍的權(quán)限委託給服務(wù)帳戶,因此新文件將歸我所有並使用我的個(gè)人儲存配額。

這樣做:將網(wǎng)域範(fàn)圍的權(quán)限委派給服務(wù)帳戶

以及如何透過 google/apiclient 從 PHP 使用 Google Drive API 的 API 金鑰

為了避免將來出現(xiàn)錯(cuò)誤和混亂,我想更改舊文件的擁有者。我不斷收到此錯(cuò)誤:

{ "error": { 
    "code": 400, 
    "message": "Bad Request. User message: "You can't change the owner of this item."", 
    "errors": [ {
       "message": "Bad Request. User message: "You can't change the owner of this item."", 
       "domain": "global", 
       "reason": "invalidSharingRequest" 
    } ] 
  } 
}

這是我使用 PHP 客戶端的程式碼

$client = new Google_Client();
$client->setApplicationName('My Name');
$client->setScopes(Google_Service_Drive::DRIVE);
$client->setAuthConfig($my_credentials);
$client->setAccessType('offline');
//$client->setSubject('my_personal_account');

$service = new Google_Service_Drive($client);

$newPermission = new Google_Service_Drive_Permission();
$newPermission->setEmailAddress('my_personal_account');
$newPermission->setType('user');
$newPermission->setRole('owner');

$service->permissions->create(
  $fileId, 
  $newPermission, 
  array("fields" => "id", "transferOwnership" => true)
);

無論客戶端是否使用 setSubject,我都會遇到相同的錯(cuò)誤。我嘗試過使用

$newPermission->setRole('writer');
$newPermission->setPendingOwner(true);

但是沒有成功。

P粉680487967
P粉680487967

全部回覆(1)
P粉571233520

只能在同一網(wǎng)域的帳戶之間轉(zhuǎn)移檔案所有權(quán)。出現(xiàn)此錯(cuò)誤的原因是服務(wù)帳戶和您的帳戶不屬於相同網(wǎng)域。

如果您有權(quán)存取共用雲(yún)端硬碟並且能夠新增具有新增檔案權(quán)限的用戶,請新增服務(wù)帳戶並使其將檔案移至共用雲(yún)端硬碟。

相關(guān)

其他相關(guān)

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板