Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a string to Amazon S3 bucket?

How can I add a string as a file on amazon s3? From whaterver I searched, I got to know that we can upload a file to s3. What is the best way to upload data without creating file?

like image 562
Sourabh Avatar asked Mar 23 '10 10:03

Sourabh


People also ask

Can S3 store text?

On Amazon S3, the only way to store data is as files, or using more accurate terminology, objects. An object can contain from 1 byte zero bytes to 5 terabytes of data, and is stored in a bucket.


1 Answers

There is an overload for the AmazonS3.putObject method that accepts the bucket string, a key string, and a string of text content. I hadn't seen mention of it on stack overflow so I'm putting this here. It's going to be similar @Jonik's answer, but without the additional dependency.

AmazonS3 s3client = AmazonS3ClientBuilder.standard().withRegion(Regions.US_EAST_1).build(); s3client.putObject(bucket, key, contents); 
like image 192
Rex NFX Avatar answered Sep 28 '22 04:09

Rex NFX