Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make blob version identifier generic #315

Open
esuomi opened this issue Dec 3, 2024 · 0 comments
Open

make blob version identifier generic #315

esuomi opened this issue Dec 3, 2024 · 0 comments
Assignees

Comments

@esuomi
Copy link
Collaborator

esuomi commented Dec 3, 2024

Some of the available API methods in BlobStoreRepository expose the blob versioning data, for example here

/**
* Upload a blob and return its generation number.
*
* @param blobDescriptor Container type describing the blob to upload.
* @return the blob generation
* @see #uploadBlob(String, InputStream)
*/
default long uploadBlob(BlobDescriptor blobDescriptor) {
if (blobDescriptor.contentType().isPresent()) {
return uploadBlob(blobDescriptor.name(), blobDescriptor.inputStream(), blobDescriptor.contentType().get());
} else {
return uploadBlob(blobDescriptor.name(), blobDescriptor.inputStream());
}
}

While GCS uses long for what it calls blob generation, AWS uses String as described here:

Each object has a version ID, whether or not S3 Versioning is enabled. (...) If you enable S3 Versioning, Amazon S3 assigns a version ID value for the object. This value distinguishes that object from other versions of the same key.

(...)

Only Amazon S3 generates version IDs, and they cannot be edited. Version IDs are Unicode, UTF-8 encoded, URL-ready, opaque strings that are no more than 1,024 bytes long. The following is an example:

3sL4kqtJlcpXroDTDmJ+rmSpXd3dIbrHY+MTRCxf3vjVBH40Nr8X8gdRQBpUMLUo

As such, I'd suggest the following:

  • make the blob versioning type Generic, <Long> for GCS, <String> for S3, and maybe <Void> for local and other implementations which do not support any blob versioning schemes
  • take the generic type into use where applicable
  • add related functionality such as adding helper methods supportsBlobVersioning(), hasBlobVersioningEnabled(), listBlobVersions()
  • add version awareness to supported operations, such as Optional<V> version field to BlobDescriptor

This is not high on priority, but something I'd see as potentially quite useful for longer term development.

Also somewhat related, I'd reduce the overall number of overloads in general through similar descriptor objects as parameters as BlobDescriptor for upload.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants