Google Cloud Storage Java Programming Model: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * Google Cloud Programmatic Access")
 
No edit summary
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
* Examples: https://github.com/googleapis/google-cloud-java/tree/master/google-cloud-examples/src/main/java/com/google/cloud/examples/storage
=Internal=
=Internal=
* [[Google Cloud Programmatic Access#Subjects|Google Cloud Programmatic Access]]
* [[Google Cloud Programmatic Access#Subjects|Google Cloud Programmatic Access]]
=Overview=
<syntaxhighlight lang='java'>
ServiceAccountCredentials serviceAccountCredentials;
Storage storageService = StorageOptions.newBuilder().setCredentials(serviceAccountCredentials).build().getService();
</syntaxhighlight>
=Bucket by Name=
<syntaxhighlight lang='java'>
ServiceAccountCredentials serviceAccountCredentials;
storageService.get(bucketName, options);
// or
storageService.get(bucketName);
</syntaxhighlight>
=List Buckets=
<syntaxhighlight lang='java'>
Page<Bucket> buckets = storageService.list();
</syntaxhighlight>
=Local Testing=
{{External|https://github.com/googleapis/google-cloud-java/blob/master/TESTING.md#testing-code-that-uses-storage}}
<syntaxhighlight lang='java'>
Storage storage = LocalStorageHelper.getOptions().getService();
</syntaxhighlight>

Latest revision as of 22:58, 3 September 2021

External

Internal

Overview

ServiceAccountCredentials serviceAccountCredentials;
Storage storageService = StorageOptions.newBuilder().setCredentials(serviceAccountCredentials).build().getService();

Bucket by Name

ServiceAccountCredentials serviceAccountCredentials;
storageService.get(bucketName, options);
// or
storageService.get(bucketName);

List Buckets

Page<Bucket> buckets = storageService.list();

Local Testing

https://github.com/googleapis/google-cloud-java/blob/master/TESTING.md#testing-code-that-uses-storage
Storage storage = LocalStorageHelper.getOptions().getService();