1- Google Cloud Java Client
2- ==========================
1+ Google Cloud Java Client for Storage
2+ ====================================
33
4- Java idiomatic client for [ Google Cloud Platform ] [ cloud-platform ] services.
4+ Java idiomatic client for [ Google Cloud Storage ] ( https://cloud.google.com/storage/ ).
55
66[ ![ Build Status] ( https://travis-ci.org/GoogleCloudPlatform/gcloud-java.svg?branch=master )] ( https://travis-ci.org/GoogleCloudPlatform/gcloud-java )
77[ ![ Coverage Status] ( https://coveralls.io/repos/GoogleCloudPlatform/gcloud-java/badge.svg?branch=master )] ( https://coveralls.io/r/GoogleCloudPlatform/gcloud-java?branch=master )
88
99- [ Homepage] (https://googlecloudplatform.github.io/gcloud-java/ )
10- - [ API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs )
10+ - [ API Documentation] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/storage/package-summary.html )
1111- [ Examples] (http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/examples/package-summary.html )
1212
13- This client supports the [ Google Cloud Storage] (https://cloud.google.com/storage/ )
14-
1513> Note: This client is a work-in-progress, and may occasionally
1614> make backwards-incompatible changes.
1715
@@ -26,6 +24,46 @@ Add this to your pom.xml file
2624</dependency >
2725```
2826
27+ Google Cloud Storage
28+ ----------------------
29+
30+ [ Google Cloud Storage] [ cloud-storage ] is a durable and highly available
31+ object storage service. Google Cloud Storage is almost infinitely scalable
32+ and guarantees consistency: when a write succeeds, the latest copy of the
33+ object will be returned to any GET, globally.
34+
35+ See the [ Google Cloud Storage docs] [ cloud-storage-activation ] for more details on how to activate
36+ Cloud Storage for your project.
37+
38+ See the `` gcloud-java `` API [ storage documentation] [ storage-api ] to learn how to interact
39+ with the Cloud Storage using this Client Library.
40+
41+ ``` java
42+ import static java.nio.charset.StandardCharsets.UTF_8 ;
43+
44+ import com.google.gcloud.storage.Blob ;
45+ import com.google.gcloud.storage.Storage ;
46+ import com.google.gcloud.storage.StorageFactory ;
47+ import com.google.gcloud.storage.StorageOptions ;
48+
49+ import java.nio.ByteBuffer ;
50+ import java.nio.channels.WritableByteChannel ;
51+
52+ StorageOptions options = StorageOptions . builder(). projectId(PROJECT_ID ). build();
53+ Storage storage = StorageFactory . instance(). get(options);
54+ Blob blob = new Blob (storage, " bucket" , " blob_name" );
55+ if (! blob. exists()) {
56+ storage2. create(blob. info(), " Hello, Cloud Storage!" . getBytes(UTF_8 ));
57+ } else {
58+ System . out. println(" Updating content for " + blob. info(). name());
59+ byte [] prevContent = blob. content();
60+ System . out. println(new String (prevContent, UTF_8 ));
61+ WritableByteChannel channel = blob. writer();
62+ channel. write(ByteBuffer . wrap(" Updated content" . getBytes(UTF_8 )));
63+ channel. close();
64+ }
65+ ```
66+
2967Testing
3068-------
3169
@@ -68,3 +106,4 @@ Apache 2.0 - See [LICENSE] for more information.
68106[ cloud-storage ] : https://cloud.google.com/storage/
69107[ cloud-storage-docs ] : https://cloud.google.com/storage/docs/overview
70108[ cloud-storage-create-bucket ] : https://cloud.google.com/storage/docs/cloud-console#_creatingbuckets
109+ [ storage-api ] : http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/storage/package-summary.html
0 commit comments