Skip to content

Commit 35ec68b

Browse files
---
yaml --- r: 31583 b: refs/heads/autosynth-containeranalysis c: 1b29001 h: refs/heads/master i: 31581: 6cb430b 31579: d0d8aa5 31575: 6fdd838 31567: 446bd04 31551: b696ae6
1 parent 5850114 commit 35ec68b

3 files changed

Lines changed: 41 additions & 13 deletions

File tree

  • branches/autosynth-containeranalysis/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ refs/heads/autosynth-bigquerydatatransfer: 71b6b6d2a992d05999b53e6e130c4fc1c8c8b
126126
refs/heads/autosynth-bigquerystorage: a345f72d7a6358e9fea9dcdae94ec85a27da3088
127127
refs/heads/autosynth-bigtable: 2a6af7e2959fd79c99b8ca5d773f29a6434b546d
128128
refs/heads/autosynth-bigtable-admin: 6379a2bc712f2736c83de0e009b4d26da4fa82ca
129-
refs/heads/autosynth-containeranalysis: 7d47fce81df96e1a0e0270cfe264fcecbfb0bb22
129+
refs/heads/autosynth-containeranalysis: 1b29001e39672994368e51ce6fae44a5528613fa
130130
refs/heads/autosynth-datastore: d0fc1187000c7a50d8bddd89c3b7cdf1187ecb96
131131
refs/heads/autosynth-dialogflow: 841930a680ebe370c9fc6ae824465f6bc51a5a46
132132
refs/heads/autosynth-errorreporting: 3f176c20b55dfaaa8fc32f28d82b31784b93e636

branches/autosynth-containeranalysis/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/Blob.java

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -512,17 +512,33 @@ public Blob reload(BlobSourceOption... options) {
512512
* current blob metadata are at their latest version use the {@code metagenerationMatch} option:
513513
* {@code newBlob.update(BlobTargetOption.metagenerationMatch())}.
514514
*
515-
* <p>Original metadata are merged with metadata in the provided in this {@code blob}. To replace
516-
* metadata instead you first have to unset them. Unsetting metadata can be done by setting this
517-
* {@code blob}'s metadata to {@code null}.
515+
* <p>Original metadata are merged with metadata in the provided {@code blobInfo}. If the original
516+
* metadata already contains a key specified in the provided {@code blobInfo's} metadata map, it
517+
* will be replaced by the new value. Removing metadata can be done by setting that metadata's
518+
* value to {@code null}.
518519
*
519-
* <p>Example of replacing blob's metadata.
520+
* <p>Example of adding new metadata values or updating existing ones.
520521
*
521522
* <pre>{@code
523+
* String bucketName = "my_unique_bucket";
524+
* String blobName = "my_blob_name";
525+
* Map<String, String> newMetadata = new HashMap<>();
526+
* newMetadata.put("keyToAddOrUpdate", "value");
527+
* Blob blob = storage.update(BlobInfo.newBuilder(bucketName, blobName)
528+
* .setMetadata(newMetadata)
529+
* .build());
530+
* }</pre>
531+
*
532+
* <p>Example of removing metadata values.
533+
*
534+
* <pre>{@code
535+
* String bucketName = "my_unique_bucket";
536+
* String blobName = "my_blob_name";
522537
* Map<String, String> newMetadata = new HashMap<>();
523-
* newMetadata.put("key", "value");
524-
* blob.toBuilder().setMetadata(null).build().update();
525-
* Blob updatedBlob = blob.toBuilder().setMetadata(newMetadata).build().update();
538+
* newMetadata.put("keyToRemove", null);
539+
* Blob blob = storage.update(BlobInfo.newBuilder(bucketName, blobName)
540+
* .setMetadata(newMetadata)
541+
* .build());
526542
* }</pre>
527543
*
528544
* @param options update options

branches/autosynth-containeranalysis/google-cloud-clients/google-cloud-storage/src/main/java/com/google/cloud/storage/Storage.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1718,17 +1718,29 @@ Blob create(
17181718

17191719
/**
17201720
* Updates blob information. Original metadata are merged with metadata in the provided {@code
1721-
* blobInfo}. To replace metadata instead you first have to unset them. Unsetting metadata can be
1722-
* done by setting the provided {@code blobInfo}'s metadata to {@code null}.
1721+
* blobInfo}. If the original metadata already contains a key specified in the provided {@code
1722+
* blobInfo's} metadata map, it will be replaced by the new value. Removing metadata can be done
1723+
* by setting that metadata's value to {@code null}.
1724+
*
1725+
* <p>Example of adding new metadata values or updating existing ones.
1726+
*
1727+
* <pre>{@code
1728+
* String bucketName = "my_unique_bucket";
1729+
* String blobName = "my_blob_name";
1730+
* Map<String, String> newMetadata = new HashMap<>();
1731+
* newMetadata.put("keyToAddOrUpdate", "value");
1732+
* Blob blob = storage.update(BlobInfo.newBuilder(bucketName, blobName)
1733+
* .setMetadata(newMetadata)
1734+
* .build());
1735+
* }</pre>
17231736
*
1724-
* <p>Example of replacing blob's metadata.
1737+
* <p>Example of removing metadata values.
17251738
*
17261739
* <pre>{@code
17271740
* String bucketName = "my_unique_bucket";
17281741
* String blobName = "my_blob_name";
17291742
* Map<String, String> newMetadata = new HashMap<>();
1730-
* newMetadata.put("key", "value");
1731-
* storage.update(BlobInfo.newBuilder(bucketName, blobName).setMetadata(null).build());
1743+
* newMetadata.put("keyToRemove", null);
17321744
* Blob blob = storage.update(BlobInfo.newBuilder(bucketName, blobName)
17331745
* .setMetadata(newMetadata)
17341746
* .build());

0 commit comments

Comments
 (0)