AWS

3 Mins Read

Conditional Writes Now Supported on Amazon S3

Voiced by Amazon Polly

Conditional Writes: An Overview

Conditional writes, which verify an object’s existence before creating it, are now supported by Amazon S3. With this feature, you may more easily stop apps from overwriting any existing objects when you upload data. PutObject or CompleteMultipartUpload API calls can be used for conditional writes in directory and general-purpose buckets, in conjunction with the HTTP if-none-match conditional header to enable conditional writes.

Customized Cloud Solutions to Drive your Business Success

  • Cloud Migration
  • Devops
  • AIML & IoT
Know More

Step 1 - Create S3 Bucket

Assuming you have an AWS user with permission to create s3 bucket and putObject permissions, also  aws cli configured on your local machine or you can use aws cloudshell to perform the below operations:

Figure 1: create s3 bucket

To view the bucket goto s3 and type the name of the bucket you created:

Figure 2: view created s3 bucket

Step 2 - Upload an Object in S3

To upload an object with the key named HappyFace.jpg, take any file image file on your local machine, rename it to HappyFace.jpg, and upload the same using the below command.

Figure 3: Upload a object using s3 aws cli

To view the uploaded object get into your s3 bucket

Figure 4: view the uploaded object

Step 3 - Upload Object Again with Same Key and without Conditional Write

Now, when uploading object with the same key named HappyFace.jpg, it will overwrite the existing object

Figure 5: upload the object with same key

Figure 6: view the uploaded object overwritten existing object

We can see in the above image the time of the object when the “Last Modified” got updated, in Figure 6, as compared to object in Figure 5.

Step 4 - Upload the Object Again with Same Key and with Conditional Write

Now if we upload an object with the same key, with conditional write, the putObject operation will fail as the specified pre-condition does not hold, as object with already exists

Figure 7: Uploading the with object with Conditional Write

Step 5 - Delete the Created Resources

Delete the object HappyFace.jpg and remove the bucket.

Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.

  • Cloud Training
  • Customized Training
  • Experiential Learning
Read More

About CloudThat

CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, and Google Cloud Platform Partner, CloudThat has empowered over 850,000 professionals through 600+ cloud certifications winning global recognition for its training excellence including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 12 awards in the last 8 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, IoT, and cutting-edge technologies like Gen AI & AI/ML. It has delivered over 500 consulting projects for 250+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.

WRITTEN BY Kamlesh N

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!