我正在使用JSON API Java庫將對象上傳到Google Cloud Storage。我已經想出瞭如何使用角色讀取器添加實體allUsers以獲得公共訪問權限,但是我試圖添加到ObjectAccessControl列表的任何其他實體/角色條目產生一些類似的錯誤,如Google Cloud Storage設置權限提供錯誤的請求錯誤Java JSON API
com.google.api。 client.googleapis.json.GoogleJsonResponseException:400錯誤的請求
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid Value",
"reason" : "invalid"
}
...每個ACL條目我有,除了ALLUSERS READER其中一個似乎工作
我不知道它在抱怨這裏。我試圖重現我在開發人員控制檯中看到的默認權限,即,當我沒有在元數據上指定任何ACL時。 業主,業主專案編號, 編輯-專案編號主人, 觀衆,讀者專案編號, 和用戶ID所有者(我猜這是服務帳戶ID)
我添加這些到ACL列表以同樣的方式作爲allUsers實體。我已經搜索了幾個小時,試圖找到一些文件或類似的問題,但只發現一個關於所有用戶。我試過轉義這些ID,認爲JSON庫可能不會這樣做,但得到相同的錯誤。
這裏是我的相關的Java代碼:
// Set permissions and content type on StorageObject metadata
StorageObject objectMetadata = new StorageObject();
// set access control
List<ObjectAccessControl> acl = Lists.newArrayList();
acl.add(new ObjectAccessControl().setEntity("allUsers").setRole("READER"));
// this one allows upload to work without error if it is the only access specified,
// but prevents me from modifying publicly available status or editing permissions
// via the developers console (I think this is to be expected)
// attempt to replicating bucket defaults...
// adding any of these will cause the error
acl.add(new ObjectAccessControl().setEntity("owners-projectId").setRole("OWNER"));
acl.add(new ObjectAccessControl().setEntityId("editors-projectId").setRole("OWNER"));
acl.add(new ObjectAccessControl().setEntityId("viewers-projectId").setRole("READER"));
objectMetadata.setAcl(acl);
其中專案編號是從開發者控制檯站點複製我的項目ID。
能否請您提供您的代碼? – jterrace 2014-09-29 15:31:15