Feature: conditional upload API #178
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #129
Adds support for conditional object uploads.
Extends
ObjectAttributes
with optionalObjectVersion
(if supported), andUpload(...)
with three newObjectUploadOption
, depending on provider support.IfMatch
: the object is written only if the existing object matches the provided versionIfNotMatch
: the object is written only if the existing object does not match the provided versionIfNotExists
: the object is written only if no object already exists for the provided keySupports two forms of
ObjectVersion
:Not all providers support conditional write. The following providers are supported:
IfNotMatch
is not yet supported (as it is not supported by AWS).Clients can check conditional API by calling
SupportedObjectUploadOptions
on theBucket
interface.Changes
API changes
ObjectUploadOption
s:IfMatch
,IfNotMatch
andIfNotExists
1.1 Made
ObjectUploadOption
typed, repeating the existingIterOption
pattern.1.2 Added three new parameter modifiers-
WithIfMatch
,WithIfNotExists
andWithIfNotMatch
, andWithContentType
to support the previous un-typedObjectUploadOption
ObjectVersion
field toObjectAttributes
IfMatch
,IfNotMatch
,IfNotExists
and forAttributes
APIBucket
provider implementations for:1.1 filesystem: this now uses Extended Attributes, if supported by the host system
1.2 inmem
1.3 GCS
1.4 Azure
1.5 S3, excepting
IfNoneMatch
which is not fully supported (by AWS) yet1.6 Wrappers
Backwards compatibility
API changes are additive and should be backwards compatible.
The
Upload
API changes use a trailing variadic parameter so should be backwards compatibleThe
ObjectAttributes
add new field so should be backwards compatibleThe
SupportedObjectUploadOptions
interface method potentially breaks existingBucket
implementations. Library users who implement their own providers will need to implement this method. Full or stub implementations are provided for all provider implementations in the libary.Dependencies
Verification
Added acceptance tests for
IfMatch
IfNotMatch
IfExists
Did not run integration tests on other object store providers, as I do not have access to test environments, but these should be unchanged.