我试图在appengine(JAVA)的一个批处理请求中设置多个ACL。我不确定提出请求的网址应该是什么。 documentation表示“/批”。有没有更多的例子可用? AFAIK这是不可能从API浏览器进行测试的。使用Google Storage Json Api(JAVA)的批量请求
1
A
回答
6
使用google-api-java-client库和存储JSON API,批量要求是这样的:
// Create the Storage service object
Storage storage = new Storage(httpTransport, jsonFactory, credential);
// Create a new batch request
BatchRequest batch = storage.batch();
// Add some requests to the batch request
storage.objectAccessControls().insert("bucket-name", "object-key1",
new ObjectAccessControl().setEntity("user-123423423").setRole("READER"))
.queue(batch, callback);
storage.objectAccessControls().insert("bucket-name", "object-key2",
new ObjectAccessControl().setEntity("[email protected]").setRole("READER"))
.queue(batch, callback);
storage.objectAccessControls().insert("bucket-name", "object-key3",
new ObjectAccessControl().setEntity("[email protected]").setRole("OWNER"))
.queue(batch, callback);
// Execute the batch request. The individual callbacks will be called when requests finish.
batch.execute();
请注意,你必须在一瞬间请求访问存储JSON API,因为它是在有限测试版。
相关的API文档是在这里:https://code.google.com/p/google-api-java-client/wiki/Batch
Java文档存储Java客户端库:https://google-api-client-libraries.appspot.com/documentation/storage/v1beta1/java/latest/index.html
+1
一个警告:如果您使用相同的资源(存储桶或对象)并针对它进行多个批量ACL编辑(插入/更新)请求,则会导致该资源发生争用,因为批量请求全部并行发生。如果您需要这样做,直到我们可以解决该问题为止,您可以编辑资源本身的acl属性,这是这些ACL的列表。 –
相关问题
- 1. Google Plus API上的批量请求
- 2. 批量请求Google日历php API
- 3. Google Calendar API批量请求PHP
- 4. Google Places API批量请求Javascript
- 5. Google Cloud Storage设置权限提供错误的请求错误Java JSON API
- 6. 如何使用python httplib或urllib2做Google API批量请求?
- 7. 使用java排队和批量请求
- 8. 在Java中使用Facebook图形API 2.5进行批量请求
- 9. 谷歌API批量请求与节点
- 10. Facebook批量请求
- 11. Google API为批量请求返回400 BadRequest
- 12. Google地图Places API中的批量请求。 - Objective C
- 13. Google Calendar V3 REST API中的批量请求
- 14. 确保Google API的批量请求每秒发生一次
- 15. 使用Java的Google Distance Matrix API的HTTP请求
- 16. Google Cloud Storage - JSON API - 原生PHP
- 17. Google Vision Java客户端批量请求响应识别
- 18. 如何在PHP中使用FullContactAPI的批量请求POST请求?
- 19. 使用Javascript的Google客户端库的批量请求
- 20. Elasticsearch使用python请求模块批量/批量索引
- 21. 批量请求的见解在Facebook上营销API(JAVA)
- 22. APNs提供程序API批量请求
- 23. Facebook API批量喜欢请求
- 24. 使用Java SDK返回400的Google Gmail API请求
- 25. 使用Retrofit的批量请求
- 26. 使用PHP的FQL批量请求
- 27. 批量请求图api iPhone xcode?
- 28. Google Cloud Storage - JAVA REST API - 获取SignatureDoesNotMatch
- 29. webapi批量请求
- 30. 无法使用Google Cloud Storage JSON API复制文件夹
你说得对,API浏览器https://developers.google.com/storage/docs/json_api/v1/objectAccessControls
关于Java客户端库批量请求文件目前不支持批量请求,这使得尝试更难一些。我建议将Java客户端库用于支持批量请求的云存储。 https://code.google.com/p/google-api-java-client/wiki/Batch + https://code.google.com/p/google-api-java-client/wiki/APIs#Cloud_Storage_API –