Conditional queries
Conditional Requests in the S3 API allow you to perform operations only if certain conditions are met using headers. They can be used to:
- perform read and write requests with a preliminary check of the object state;
- manage updates and downloads of objects based on their current state or metadata;
- conform to the familiar scenarios of working to S3 standards;
- protect data from accidental overwriting;
- optimize traffic costs.
Conditional queries can be used for different scenarios.
Headings
PutObject operations
For examples of loading objects with conditions, see the Load Object subsection of the AWS CLI instructions .
CopyObject and UploadPartCopy operations
For examples of copying objects with conditions, see the Copy Object subsection of the AWS CLI instructions .
DeleteObject operations
For examples of deleting objects with conditions, see the Delete Object subsection of the AWS CLI instructions .
CompleteMultipartUpload operations
Error description
Examples of use cases
- update conflict protection - the object will be updated only if it has not changed since the last invocation (
If-Matchheader); - data synchronization - the object will be loaded only if it was changed after the specified time (
If-Modified-Sinceheader); - read optimization - the object will be retrieved only if it does not match the local version (
If-None-Matchheader); - overwriting protection - the object will not be written by key
ifthere is already another object with the same key (If-None-Matchheader).