Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,19 +306,21 @@ public Blob updateBlob(String bucketName, String blobName) {
}

/**
* Example of udating a blob, only if the blob's metageneration matches a value, otherwise a
* Example of updating a blob, only if the blob's metageneration matches a value, otherwise a
* {@link StorageException} is thrown.
*/
// [TARGET update(BlobInfo, BlobTargetOption...)]
// [VARIABLE "my_unique_bucket"]
// [VARIABLE "my_blob_name"]
public Blob updateBlobWithMetageneration(String bucketName, String blobName) {
// [START updateBlobWithMetageneration]
Map<String, String> newMetadata = new HashMap<>();
newMetadata.put("key", "value");
Blob blob = storage.get(bucketName, blobName);
BlobInfo updatedInfo = blob.toBuilder().setContentType("text/plain").build();
storage.update(updatedInfo, BlobTargetOption.metagenerationMatch());
BlobInfo updatedInfo = blob.toBuilder().setContentType("text/plain").setMetadata(map).build();
Blob updated=storage.update(updatedInfo, BlobTargetOption.metagenerationMatch());
// [END updateBlobWithMetageneration]
return blob;
return updated;
}

/**
Expand Down