- Newest
- Most votes
- Most comments
Thank you for providing detailed information about your issue with S3 conditional writes using pre-signed URLs. You're correct that there seems to be a discrepancy between the documentation and the actual behavior you're experiencing.
The error message you're receiving indicates that for conditional writes using the If-Match header, AWS is requiring both HTTPS and AWS Signature Version 4 (SigV4), not just one or the other as the documentation suggests.
Your observation about the "AND" requirement instead of "OR" appears to be accurate. This is indeed a limitation when trying to use conditional writes with pre-signed URLs from a browser environment where you can't use SigV4 signing.
Regarding your notes:
-
The "*" value for the If-Match header is not supported for this API, which explains the error you received.
-
The fact that If-None-Match: * works as expected is consistent with the intended behavior for preventing overwrites of existing objects.
For your use case of uploading attachments from a web UI to an S3 bucket while preventing object overwrites, you might consider the following alternatives:
-
Use server-side logic to handle the upload and apply the conditional write checks. This way, you can use SigV4 signing on the server.
-
Use the If-None-Match: * header instead of If-Match, as you've found it works. This will prevent overwrites of existing objects but won't give you the fine-grained control that ETag matching provides.
-
Implement a two-step process where you first check the object's existence and ETag on the server, then generate a pre-signed URL with appropriate conditions.
It would be beneficial to report this discrepancy to AWS support or through their documentation feedback channels to help clarify the requirements for conditional writes with pre-signed URLs.
Sources
How to prevent object overwrites with conditional writes - Amazon Simple Storage Service
Enforce conditional writes on Amazon S3 buckets - Amazon Simple Storage Service
PutObject - Amazon Simple Storage Service
answered a year ago
Relevant content
asked 3 years ago
