use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.
the class SyncGetObjectStringStringLong method syncGetObjectStringStringLong.
public static void syncGetObjectStringStringLong() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
String bucket = "bucket-1378203158";
String object = "object-1023368385";
long generation = 305703192;
Object response = storageClient.getObject(bucket, object, generation);
}
}
use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.
the class SyncDeleteObjectStringStringLong method syncDeleteObjectStringStringLong.
public static void syncDeleteObjectStringStringLong() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
String bucket = "bucket-1378203158";
String object = "object-1023368385";
long generation = 305703192;
storageClient.deleteObject(bucket, object, generation);
}
}
use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.
the class AsyncDeleteObject method asyncDeleteObject.
public static void asyncDeleteObject() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
DeleteObjectRequest request = DeleteObjectRequest.newBuilder().setBucket("bucket-1378203158").setObject("object-1023368385").setUploadId("uploadId1563990780").setGeneration(305703192).setIfGenerationMatch(-1086241088).setIfGenerationNotMatch(1475720404).setIfMetagenerationMatch(1043427781).setIfMetagenerationNotMatch(1025430873).setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
ApiFuture<Empty> future = storageClient.deleteObjectCallable().futureCall(request);
// Do something.
future.get();
}
}
use of com.google.storage.v2.Object in project gapic-generator-java by googleapis.
the class SyncComposeObject method syncComposeObject.
public static void syncComposeObject() throws Exception {
// It may require modifications to work in your environment.
try (StorageClient storageClient = StorageClient.create()) {
ComposeObjectRequest request = ComposeObjectRequest.newBuilder().setDestination(Object.newBuilder().build()).addAllSourceObjects(new ArrayList<ComposeObjectRequest.SourceObject>()).setDestinationPredefinedAcl(PredefinedObjectAcl.forNumber(0)).setIfGenerationMatch(-1086241088).setIfMetagenerationMatch(1043427781).setKmsKey(CryptoKeyName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY]").toString()).setCommonObjectRequestParams(CommonObjectRequestParams.newBuilder().build()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
Object response = storageClient.composeObject(request);
}
}
use of com.google.storage.v2.Object in project grpc-gcp-java by GoogleCloudPlatform.
the class GrpcClient method makeRandomReadRequest.
private void makeRandomReadRequest(ManagedChannel channel, ResultTable results, int threadId) {
StorageBlockingStub blockingStub = StorageGrpc.newBlockingStub(channel);
if (creds != null) {
blockingStub = blockingStub.withCallCredentials(MoreCallCredentials.from(creds));
}
String object = objectResolver.Resolve(threadId, /*objectId=*/
0);
ReadObjectRequest.Builder reqBuilder = ReadObjectRequest.newBuilder().setBucket(toV2BucketName(args.bkt)).setObject(object);
Random r = new Random();
long buffSize = args.buffSize * 1024;
byte[] scratch = new byte[4 * 1024 * 1024];
for (int i = 0; i < args.calls; i++) {
long offset = (long) r.nextInt(args.size - args.buffSize) * 1024;
reqBuilder.setReadOffset(offset);
reqBuilder.setReadLimit(buffSize);
ReadObjectRequest req = reqBuilder.build();
long start = System.currentTimeMillis();
Iterator<ReadObjectResponse> resIterator = blockingStub.readObject(req);
while (resIterator.hasNext()) {
ReadObjectResponse res = resIterator.next();
ByteString content = res.getChecksummedData().getContent();
content.copyTo(scratch, 0);
}
long dur = System.currentTimeMillis() - start;
results.reportResult(args.bkt, object, buffSize, dur);
}
}
Aggregations