1

我正在尝试在来自 appengine (JAVA) 的一批请求中设置多个 ACL。我不确定发出请求的 URL 应该是什么。文档说明“ /batch”。是否还有可用的示例?AFAIK 无法从 API Explorer 进行测试。

4

1 回答 1

6

使用google-api-java-client库和 Storage 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("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,因为它处于有限的测试阶段。

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

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

存储 Java 客户端库的 JavaDoc:https ://google-api-client-libraries.appspot.com/documentation/storage/v1beta1/java/latest/index.html

于 2012-12-04T14:49:09.007 回答