Question:
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:
- file name:
userlist.json
- grab content of file using S3 provide methods
- eg: existing file contents are
{'abc','xyz'}
- add additional contents
{'abc','xyz'}, {'zxv','opiv','cvpo'}
- update newly added content into S3 bucket file (
userlist.json
)
How we can do this ?
Answer:
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.