@@ -14,6 +14,7 @@ Java idiomatic client for [Google Cloud Platform][cloud-platform] services.
14
14
This client supports the following Google Cloud Platform services:
15
15
16
16
- [ Google Cloud Datastore] (#google-cloud-datastore)
17
+ - [ Google Cloud Storage] (#google-cloud-storage)
17
18
18
19
<!-- -
19
20
- [Google Cloud Storage] (https://cloud.google.com/storage/)
@@ -44,7 +45,7 @@ Example Applications
44
45
Google Cloud Datastore
45
46
----------------------
46
47
47
- Google [ Cloud Datastore] [ cloud-datastore ] is a fully managed, schemaless database for
48
+ [ Google Cloud Datastore] [ cloud-datastore ] is a fully managed, schemaless database for
48
49
storing non-relational data. Cloud Datastore automatically scales with
49
50
your users and supports ACID transactions, high availability of reads and
50
51
writes, strong consistency for reads and ancestor queries, and eventual
@@ -86,6 +87,46 @@ if (entity == null) {
86
87
}
87
88
```
88
89
90
+ Google Cloud Storage
91
+ ----------------------
92
+
93
+ [ Google Cloud Storage] [ cloud-storage ] is a durable and highly available
94
+ object storage service. Google Cloud Storage is almost infinitely scalable
95
+ and guarantees consistency: when a write succeeds, the latest copy of the
96
+ object will be returned to any GET, globally.
97
+
98
+ See the [ Google Cloud Storage docs] [ cloud-storage-activation ] for more details on how to activate
99
+ Cloud Storage for your project.
100
+
101
+ See the `` gcloud-java `` API [ storage documentation] [ storage-api ] to learn how to interact
102
+ with the Cloud Storage using this Client Library.
103
+
104
+ ``` java
105
+ import static java.nio.charset.StandardCharsets.UTF_8 ;
106
+
107
+ import com.google.gcloud.storage.Blob ;
108
+ import com.google.gcloud.storage.Storage ;
109
+ import com.google.gcloud.storage.StorageFactory ;
110
+ import com.google.gcloud.storage.StorageOptions ;
111
+
112
+ import java.nio.ByteBuffer ;
113
+ import java.nio.channels.WritableByteChannel ;
114
+
115
+ StorageOptions options = StorageOptions . builder(). projectId(PROJECT_ID ). build();
116
+ Storage storage = StorageFactory . instance(). get(options);
117
+ Blob blob = new Blob (storage, " bucket" , " blob_name" );
118
+ if (! blob. exists()) {
119
+ storage2. create(blob. info(), " Hello, Cloud Storage!" . getBytes(UTF_8 ));
120
+ } else {
121
+ System . out. println(" Updating content for " + blob. info(). name());
122
+ byte [] prevContent = blob. content();
123
+ System . out. println(new String (prevContent, UTF_8 ));
124
+ WritableByteChannel channel = blob. writer();
125
+ channel. write(ByteBuffer . wrap(" Updated content" . getBytes(UTF_8 )));
126
+ channel. close();
127
+ }
128
+ ```
129
+
89
130
Contributing
90
131
------------
91
132
@@ -130,3 +171,5 @@ Apache 2.0 - See [LICENSE] for more information.
130
171
[ cloud-storage ] : https://cloud.google.com/storage/
131
172
[ cloud-storage-docs ] : https://cloud.google.com/storage/docs/overview
132
173
[ cloud-storage-create-bucket ] : https://cloud.google.com/storage/docs/cloud-console#_creatingbuckets
174
+ [ cloud-storage-activation ] : https://cloud.google.com/storage/docs/signup
175
+ [ storage-api ] : http://googlecloudplatform.github.io/gcloud-java/apidocs/index.html?com/google/gcloud/storage/package-summary.html
0 commit comments