Skip to content

Storage::writer() provides no way to see metadata after writing. #2343

Description

@BrandonY

Here's an example of using the Storage::writer method to write a blob from the documentation:

BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType("text/plain").build();
try (WriteChannel writer = storage.writer(blobInfo)) {
   try {
      writer.write(ByteBuffer.wrap(content, 0, content.length));
   } catch (Exception ex) {
     // handle exception
   }
}

This works well and makes it easy to write data to a GCS object with a WriteChannel. However, when the operation finishes, GCS returns the metadata of the new object, most importantly including the generation number of the newly-created object. The writer() method provides no way of accessing this metadata.

We need a way of accessing the metadata of the new object upon success. Perhaps a Blob accessor could be added to the WriteChannel, or some assignable reference could be passed to the writer() method, or some other mechanism.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions