@@ -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
0 commit comments