Skip to content

Commit 0008d41

Browse files
committed
---
yaml --- r: 6311 b: refs/heads/tswast-patch-1 c: d51311e h: refs/heads/master i: 6309: 7297311 6307: c244d75 6303: 2358851
1 parent 5be2769 commit 0008d41

5 files changed

Lines changed: 26 additions & 28 deletions

File tree

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ refs/tags/v0.18.0: 9d193c4c4b9d1c6f21515dd8e50836b9194ec9bb
5757
refs/tags/v0.19.0: e67b56e4d8dad5f9a7b38c9b2107c23c828f2ed5
5858
refs/tags/v0.20.0: 839f7fb7156535146aa1cb2c5aadd8d375d854e8
5959
refs/tags/v0.20.1: 370471f437f1f4f68a11e068df5cd6bf39edb1fa
60-
refs/heads/tswast-patch-1: 32e75217e0bd703c74c0a5b2d90dfc51b15acd02
60+
refs/heads/tswast-patch-1: d51311ec8c80bab05fae712f4498e132396e22b0
6161
refs/heads/pubsub-streaming-pull: 19262b752ee874eb2ca3b950eb2aef44d5a5267b

branches/tswast-patch-1/README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,20 +104,23 @@ Here is a code snippet showing a simple usage example from within Compute/App En
104104
import static java.nio.charset.StandardCharsets.UTF_8;
105105

106106
import com.google.gcloud.storage.Blob;
107+
import com.google.gcloud.storage.BlobId;
107108
import com.google.gcloud.storage.Storage;
108109
import com.google.gcloud.storage.StorageFactory;
109110
import com.google.gcloud.storage.StorageOptions;
110111

111112
import java.nio.ByteBuffer;
112113
import java.nio.channels.WritableByteChannel;
113114

114-
Storage storage = StorageFactory.instance().get(StorageOptions.getDefaultInstance());
115-
Blob blob = new Blob(storage,
116-
BlobInfo.builder("bucket", "blob_name").contentType("text/plain").build());
117-
if (!blob.exists()) {
118-
storage2.create(blob.info(), "Hello, Cloud Storage!".getBytes(UTF_8));
115+
StorageOptions options = StorageOptions.builder().projectId("project").build();
116+
Storage storage = StorageFactory.instance().get(options);
117+
BlobId blobId = BlobId.of("bucket", "blob_name");
118+
Blob blob = Blob.load(storage, blobId);
119+
if (blob == null) {
120+
BlobInfo blobInfo = BlobInfo.builder(blobId).contentType("text/plain").build();
121+
storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));
119122
} else {
120-
System.out.println("Updating content for " + blob.info().name());
123+
System.out.println("Updating content for " + blobId.name());
121124
byte[] prevContent = blob.content();
122125
System.out.println(new String(prevContent, UTF_8));
123126
WritableByteChannel channel = blob.writer();

branches/tswast-patch-1/gcloud-java-examples/src/main/java/com/google/gcloud/examples/StorageExample.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.nio.ByteBuffer;
4242
import java.nio.channels.Channels;
4343
import java.nio.channels.WritableByteChannel;
44+
import static java.nio.charset.StandardCharsets.UTF_8;
4445
import java.nio.file.Files;
4546
import java.nio.file.Path;
4647
import java.nio.file.Paths;
@@ -178,22 +179,15 @@ public String params() {
178179
private static class DeleteAction extends BlobsAction {
179180
@Override
180181
public void run(Storage storage, BlobId... blobIds) {
181-
if (blobIds.length == 1) {
182-
Blob blob = Blob.load(storage, blobIds[0]);
183-
if (blob != null && blob.delete()) {
184-
System.out.println("Blob " + blob.info() + " was deleted");
185-
}
186-
} else {
187-
// use batch operation
188-
List<Boolean> deleteResults = Blob.delete(storage, blobIds);
189-
int index = 0;
190-
for (Boolean deleted : deleteResults) {
191-
if (deleted) {
192-
// request order is maintained
193-
System.out.println("Blob " + blobIds[index] + " was deleted");
194-
}
195-
index++;
182+
// use batch operation
183+
List<Boolean> deleteResults = Blob.delete(storage, blobIds);
184+
int index = 0;
185+
for (Boolean deleted : deleteResults) {
186+
if (deleted) {
187+
// request order is maintained
188+
System.out.println("Blob " + blobIds[index] + " was deleted");
196189
}
190+
index++;
197191
}
198192
}
199193
}

branches/tswast-patch-1/gcloud-java-storage/src/main/java/com/google/gcloud/storage/Storage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ public static Builder builder() {
695695
* <p>
696696
* Example usage of creating a signed URL that is valid for 2 weeks:
697697
* <pre> {@code
698-
* service.signUrl(BlobInfo.of("bucket", "name"), 14, TimeUnit.DAYS);
698+
* service.signUrl(BlobInfo.builder("bucket", "name").build(), 14, TimeUnit.DAYS);
699699
* }</pre>
700700
*
701701
* @param blobInfo the blob associated with the signed URL

branches/tswast-patch-1/gcloud-java-storage/src/main/java/com/google/gcloud/storage/package-info.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@
2121
* <pre>{@code
2222
* StorageOptions options = StorageOptions.builder().projectId("project").build();
2323
* Storage storage = StorageFactory.instance().get(options);
24-
* Blob blob = new Blob(storage,
25-
* BlobInfo.builder("bucket", "blob_name").contentType("text/plain").build());
26-
* if (!blob.exists()) {
27-
* storage.create(blob.info(), "Hello, Cloud Storage!".getBytes(UTF_8));
24+
* BlobId blobId = BlobId.of("bucket", "blob_name");
25+
* Blob blob = Blob.load(storage, blobId);
26+
* if (blob == null) {
27+
* BlobInfo blobInfo = BlobInfo.builder(blobId).contentType("text/plain").build();
28+
* storage.create(blobInfo, "Hello, Cloud Storage!".getBytes(UTF_8));
2829
* } else {
29-
* System.out.println("Updating content for " + blob.info().name());
30+
* System.out.println("Updating content for " + blobId.name());
3031
* byte[] prevContent = blob.content();
3132
* System.out.println(new String(prevContent, UTF_8));
3233
* WritableByteChannel channel = blob.writer();

0 commit comments

Comments
 (0)