-
Notifications
You must be signed in to change notification settings - Fork 89
Description
Documentation for Blob.writer(BlobWriterOption...) recommends the following way to upload information:
byte[] content = "Hello, World!".getBytes(UTF_8);
try (WriteChannel writer = blob.writer()) {
try {
writer.write(ByteBuffer.wrap(content, 0, content.length));
} catch (Exception ex) {
// handle exception
}
}
But doc is silent on how to renew the blob object, which is a bit tricky because neither blob.reload() nor storage.getBlob(blob.getBlobId()) does not help. Behavior varies depending on versioning setting for the bucket.
If versioning is enabled:
Attempt to reload as recommended:
blob.reload(Blob.BlobSourceOption.generationNotMatch()) causes StorageException '304 Not Modified'
blob.reload() returns the same blob.
storage.get(blob.getBlobId()) returns the same blob (that seems very confusing).
And only storage.get(blobId) returns the updated blob.
If versioning is Suspended:
before upload: blob.getContent() returns an empty array
After upload: blob.getContent() throws StorageException: 404 Not Found , No such object
storage.get(blob.getBlobId()), blob.reload() and blob.reload(Blob.BlobSourceOption.generationNotMatch()) return null.
And again only storage.get(blobId) returns the updated blob.