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

Support conditional put in TransferUtility (S3) #3451

Closed
1 of 2 tasks
leidegre opened this issue Aug 22, 2024 · 3 comments
Closed
1 of 2 tasks

Support conditional put in TransferUtility (S3) #3451

leidegre opened this issue Aug 22, 2024 · 3 comments
Assignees
Labels
feature-request A feature should be added or improved. p3 This is a minor priority issue s3

Comments

@leidegre
Copy link

leidegre commented Aug 22, 2024

Describe the feature

There's currently no way to include a If-None-Match: * or similar condition with the transfer operation. It's not that S3 doesn't support this but it's not possible to pass this information to the CompleteMultipartUpload operation.

Use Case

I use If-None-Match: * specifically to prevent overwriting stuff already in storage.

Proposed Solution

Simply make it possible to add If-None-Match: * to TransferUtilityUploadRequest. Currently there's no way to influence the CompleteMultipartUpload operation via the TransferUtilityUploadRequest.

Other Information

I've snooped around the code and the only way I managed to do this of the V3 code, is this.

class AmazonX3CompleteMultipartUploadRequestMarshaller : IMarshaller<IRequest, CompleteMultipartUploadRequest>, IMarshaller<IRequest, AmazonWebServiceRequest>
{
	public IRequest Marshall(AmazonWebServiceRequest input)
	{
		return Marshall((CompleteMultipartUploadRequest)input);
	}

	public IRequest Marshall(CompleteMultipartUploadRequest input)
	{
		var req = CompleteMultipartUploadRequestMarshaller.Instance.Marshall(input);
		req.Headers["If-None-Match"] = "*";
		return req;
	}
}

class AmazonX3Client : AmazonS3Client
{
	public AmazonX3CompleteMultipartUploadRequestMarshaller CompleteMultipartUploadRequestMarshaller { get; } = new();

	public AmazonX3Client(AWSCredentials credentials, AmazonS3Config config) : base(credentials, config) { }

	public override Task<CompleteMultipartUploadResponse> CompleteMultipartUploadAsync(CompleteMultipartUploadRequest request, CancellationToken cancellationToken = default)
	{
		InvokeOptions options = new InvokeOptions();
		options.RequestMarshaller = CompleteMultipartUploadRequestMarshaller;
		options.ResponseUnmarshaller = CompleteMultipartUploadResponseUnmarshaller.Instance;
		return InvokeAsync<CompleteMultipartUploadResponse>(request, options, cancellationToken);
	}
}

I would prefer to use the TransferUtility but I need to be able to make it a conditional PUT that won't overwrite what is already in storage.

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS .NET SDK and/or Package version used

AWSSDK.S3 3.7.401.2

Targeted .NET Platform

.NET 8

Operating System and version

Windows 11

@leidegre leidegre added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Aug 22, 2024
@leidegre
Copy link
Author

leidegre commented Aug 22, 2024

On second thought, my solution to this problem will work with the TransferUtility, there should be no need for this because I can pass my AmazonX3Client to the TransferUtility instance and it should do the right thing.

Copy link

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@ashishdhingra ashishdhingra added s3 p3 This is a minor priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Oct 9, 2024
@ashishdhingra ashishdhingra self-assigned this Oct 9, 2024
@ashishdhingra
Copy link
Contributor

Thanks for self resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p3 This is a minor priority issue s3
Projects
None yet
Development

No branches or pull requests

2 participants