使用Google Storage Json Api(JAVA)进行批处理请求 [英] Batch request with Google Storage Json Api (JAVA)

查看:141
本文介绍了使用Google Storage Json Api(JAVA)进行批处理请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在来自appengine(JAVA)的一个批处理请求中设置多个ACL.我不确定发出请求的网址应该是什么. 文档注明"/batch".是否有可用的示例了? AFAIK无法通过API资源管理器进行测试.

I'm attempting to set multiple ACLs in one batch request from appengine (JAVA). I am not sure what the URL should be for making the request. The documentation states "/batch". Are there anymore examples available? AFAIK this is not possible to test from the API explorer.

推荐答案

使用 google-api-java-client 库和Storage JSON API,批处理请求将如下所示:

Using the google-api-java-client library and the Storage JSON API, a batch request would look like this:

// 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("user-guy@example.com").setRole("READER"))
    .queue(batch, callback);
storage.objectAccessControls().insert("bucket-name", "object-key3",
    new ObjectAccessControl().setEntity("group-foo@googlegroups.com").setRole("OWNER"))
    .queue(batch, callback);

// Execute the batch request. The individual callbacks will be called when requests finish.
batch.execute();

请注意,由于它的测试版有限,此刻您必须请求访问Storage JSON API.

Note that you'll have to request access to the Storage JSON API at the moment, as it's in limited beta.

相关的API文档在这里: https://developers.google.com/storage/docs/json_api/v1/objectAccessControls

Relevant API documentation is here: https://developers.google.com/storage/docs/json_api/v1/objectAccessControls

Java客户端库中有关批处理请求的文档: https: //code.google.com/p/google-api-java-client/wiki/Batch

Documentation about batch requests in the Java client library: https://code.google.com/p/google-api-java-client/wiki/Batch

用于存储Java客户端库的JavaDoc:

JavaDoc for the Storage Java client library: https://google-api-client-libraries.appspot.com/documentation/storage/v1beta1/java/latest/index.html

这篇关于使用Google Storage Json Api(JAVA)进行批处理请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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