You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: branches/update-datastore/README.md
+3-10Lines changed: 3 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,9 +75,7 @@ Most `gcloud-java` libraries require a project ID. There are multiple ways to s
75
75
Authentication
76
76
--------------
77
77
78
-
First, ensure that the necessary Google Cloud APIs are enabled for your project. To do this, follow the instructions on the [authentication document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/authentication/readme.md#authentication) shared by all the gcloud language libraries.
79
-
80
-
Next, choose a method for authenticating API requests from within your project:
78
+
There are multiple ways to authenticate to use Google Cloud services.
81
79
82
80
1. When using `gcloud-java` libraries from within Compute/App Engine, no additional authentication steps are necessary.
83
81
2. When using `gcloud-java` libraries elsewhere, there are two options:
@@ -182,11 +180,6 @@ if (blob == null) {
182
180
}
183
181
```
184
182
185
-
Troubleshooting
186
-
---------------
187
-
188
-
To get help, follow the `gcloud-java` links in the `gcloud-*` [shared Troubleshooting document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
189
-
190
183
Java Versions
191
184
-------------
192
185
@@ -213,7 +206,7 @@ Contributing
213
206
214
207
Contributions to this library are always welcome and highly encouraged.
215
208
216
-
See `gcloud-java`'s [CONTRIBUTING] documentation and the `gcloud-*` [shared documentation](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud) for more information on how to get started.
209
+
See [CONTRIBUTING] for more information on how to get started.
217
210
218
211
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more information.
219
212
@@ -224,7 +217,7 @@ Apache 2.0 - See [LICENSE] for more information.
To get help, follow the `gcloud-java` links in the `gcloud-*`[shared Troubleshooting document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
36
-
37
32
Java Versions
38
33
-------------
39
34
@@ -44,9 +39,7 @@ Contributing
44
39
45
40
Contributions to this library are always welcome and highly encouraged.
46
41
47
-
See `gcloud-java`'s [CONTRIBUTING] documentation and the `gcloud-*`[shared documentation](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud) for more information on how to get started.
48
-
49
-
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more information.
42
+
See [CONTRIBUTING] for more information on how to get started.
50
43
51
44
Versioning
52
45
----------
@@ -64,6 +57,5 @@ Apache 2.0 - See [LICENSE] for more information.
Copy file name to clipboardExpand all lines: branches/update-datastore/gcloud-java-datastore/README.md
+1-9Lines changed: 1 addition & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -189,11 +189,6 @@ public class GcloudJavaDatastoreExample {
189
189
}
190
190
```
191
191
192
-
Troubleshooting
193
-
---------------
194
-
195
-
To get help, follow the `gcloud-java` links in the `gcloud-*`[shared Troubleshooting document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
196
-
197
192
Java Versions
198
193
-------------
199
194
@@ -220,9 +215,7 @@ Contributing
220
215
221
216
Contributions to this library are always welcome and highly encouraged.
222
217
223
-
See `gcloud-java`'s [CONTRIBUTING] documentation and the `gcloud-*`[shared documentation](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud) for more information on how to get started.
224
-
225
-
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more information.
218
+
See [CONTRIBUTING] for more information on how to get started.
226
219
227
220
License
228
221
-------
@@ -231,7 +224,6 @@ Apache 2.0 - See [LICENSE] for more information.
To get help, follow the `gcloud-java` links in the `gcloud-*`[shared Troubleshooting document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
65
-
66
61
Java Versions
67
62
-------------
68
63
@@ -82,9 +77,7 @@ Contributing
82
77
83
78
Contributions to this library are always welcome and highly encouraged.
84
79
85
-
See `gcloud-java`'s [CONTRIBUTING] documentation and the `gcloud-*`[shared documentation](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud) for more information on how to get started.
86
-
87
-
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more information.
80
+
See [CONTRIBUTING] for more information on how to get started.
88
81
89
82
License
90
83
-------
@@ -93,7 +86,6 @@ Apache 2.0 - See [LICENSE] for more information.
@@ -56,36 +56,162 @@ Cloud Storage for your project.
56
56
See the ``gcloud-java`` API [storage documentation][storage-api] to learn how to interact
57
57
with the Cloud Storage using this Client Library.
58
58
59
-
Here is a code snippet showing a simple usage example from within Compute/App Engine. Note that you must [supply credentials](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) and a project ID if running this snippet elsewhere.
59
+
Getting Started
60
+
---------------
61
+
#### Prerequisites
62
+
For this tutorial, you will need a [Google Developers Console](https://console.developers.google.com/) project with the Storage JSON API enabled. You will need to [enable billing](https://support.google.com/cloud/answer/6158867?hl=en) to use Google Cloud Storage. [Follow these instructions](https://cloud.google.com/docs/authentication#preparation) to get your project set up. You will also need to set up the local development environment by [installing the Google Cloud SDK](https://cloud.google.com/sdk/) and running the following commands in command line: `gcloud auth login` and `gcloud config set project [YOUR PROJECT ID]`.
63
+
64
+
#### Installation and setup
65
+
You'll need to obtain the `gcloud-java-storage` library. See the [Quickstart](#quickstart) section to add `gcloud-java-storage` as a dependency in your code.
66
+
67
+
#### Creating an authorized service object
68
+
To make authenticated requests to Google Cloud Storage, you must create a service object with credentials. You can then make API calls by calling methods on the Storage service object. The simplest way to authenticate is to use [Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials). These credentials are automatically inferred from your environment, so you only need the following code to create your service object:
For other authentication options, see the [Authentication](https://github.com/GoogleCloudPlatform/gcloud-java#authentication) page.
78
+
79
+
#### Storing data
80
+
Stored objects are called "blobs" in `gcloud-java` and are organized into containers called "buckets". In this code snippet, we will create a new bucket and upload a blob to that bucket.
81
+
82
+
Add the following imports at the top of your file:
Then add the following code to create a bucket and upload a simple blob.
93
+
94
+
*Important: Bucket names have to be globally unique. If you choose a bucket name that already exists, you'll get a helpful error message telling you to choose another name. In the code below, replace "my_unique_bucket" with a unique bucket name.*
95
+
96
+
```java
97
+
// Create a bucket
98
+
String bucketName ="my_unique_bucket"; // Remember to change this to something unique
If others have permission to edit the blob, then you may want to call `reload` to get a more up to date copy of the blob later in your program. The following snippet shows how to get a new Blob object containing updated information.
124
+
125
+
```
126
+
Blob refreshedBlob = blob.reload();
127
+
```
128
+
129
+
#### Listing buckets and contents of buckets
130
+
Suppose that you've added more buckets and blobs, and now you want to see the names of your buckets and the contents of each one. Add the following imports:
131
+
132
+
```java
133
+
importcom.google.gcloud.storage.Bucket;
134
+
135
+
importjava.util.Iterator;
136
+
```
137
+
138
+
Then add the following code to list all your buckets and all the blobs inside your newly created bucket.
To get help, follow the `gcloud-java` links in the `gcloud-*`[shared Troubleshooting document](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/troubleshooting/readme.md#troubleshooting).
159
+
Here we put together all the code shown above into one program. This program assumes that you are running on Compute Engine or from your own desktop. To run this example on App Engine, simply move the code from the main method to your application's servlet class and change the print statements to display on your webpage.
Contributions to this library are always welcome and highly encouraged.
115
241
116
-
See `gcloud-java`'s [CONTRIBUTING] documentation and the `gcloud-*`[shared documentation](https://github.com/GoogleCloudPlatform/gcloud-common/blob/master/contributing/readme.md#how-to-contribute-to-gcloud) for more information on how to get started.
117
-
118
-
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct][code-of-conduct] for more information.
242
+
See [CONTRIBUTING] for more information on how to get started.
119
243
120
244
License
121
245
-------
@@ -124,7 +248,6 @@ Apache 2.0 - See [LICENSE] for more information.
0 commit comments