Google Cloud Storage Java Programming Model: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 21: Line 21:
=Local Testing=
=Local Testing=
{{External|https://github.com/googleapis/google-cloud-java/blob/master/TESTING.md#testing-code-that-uses-storage}}
{{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>

Revision as of 00:22, 3 September 2021

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();