Can we update contents of a specific file in Amazon S3?


I am using AWS PHP SDK. I uploaded a JSON file to S3 bucket. Now I would like to get the file contents(uploaded to S3 bucket), add some additional text to the grabbed file contents and update that file over the S3 bucket.

What I want is something like this:

  1. file name: userlist.json
  2. grab content of file using S3 provide methods
  3. eg: existing file contents are {'abc','xyz'}
  4. add additional contents {'abc','xyz'}, {'zxv','opiv','cvpo'}
  5. update newly added content into S3 bucket file (userlist.json)

How we can do this ?


You can’t add data to, or modify just part of an existing s3 object, you need to read the object, make changes to the object, and the write the entire object back to s3.

Leave a Reply