Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 847
Qazi Avatar asked Jan 13 '16 07:01

Qazi


People also ask

What file formats does Amazon S3 Select support?

Amazon S3 Select works on objects stored in CSV, JSON, or Apache Parquet format. It also works with objects that are compressed with GZIP or BZIP2 (for CSV and JSON objects only), and server-side encrypted objects. You can specify the format of the results as either CSV or JSON, and you can determine how the records in the result are delimited.

Why can't I upload files to Amazon S3?

Make sure you have free space in your storage, and your uploads correspond to Amazon S3 file requirements. Then you may need to check your host settings: go to Downloads - Settings - Extensions - Amazon S3. Is your host set up correctly?

How to append to an existing file on AWS S3?

It's not possible to append to an existing file on AWS S3. You can delete existing file and upload new file with same name. private string bucketName = "my-bucket-name-123"; private static string awsAccessKey = "AKI............"; private static string awsSecretKey = "+8Bo..................................";

How do I Find my Files in Amazon S3?

In Amazon S3, folders help you to find your files thanks to prefixes (located before the key name). Let’s say you create a folder named Images, and there you store an object with the key name images/photo1.jpg. “Images” is the prefix in this case. “/” is the delimiter, automatically added by the system (avoid them in your folder names).


1 Answers

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.

like image 170
E.J. Brennan Avatar answered Oct 17 '22 07:10

E.J. Brennan