2

Is there a method to write/create a text file to S3 bucket in AWS SDK?

Ramesh Murugesan
  • 4,727
  • 7
  • 42
  • 67

3 Answers3

2

This may helpful. I use ZenS3 (https://github.com/cyberbuff/ZenS3). It has a method putObjectString(). Just pass string to putObjectString method. It will create a file in S3 Bucket. Make sure your bucket should be in US region.

Ila
  • 195
  • 13
0

Amazon S3 works via HTTP REST API.

There are methods in the SDK's to write a string to a file in S3: for example the set_contents_from_string method.

There are different S3 clients that provide an ease of use to S3 like CloudBerry and DragonDisk

Shimon Tolts
  • 1,602
  • 14
  • 15
0

Can use this overload of AmazonS3.putObject(). REST API described here.

"content: The String to encode" will be written to the file as content as it is. Word encode might be a bit confusing.

/**
 * <p>
 * Encodes a String into the contents of an S3 object.
 * </p>
 * <p>
 * String will be encoded to bytes with UTF-8 encoding.
 * </p>
 *
 * @param bucketName
 *            The name of the bucket to place the new object in.
 * @param key
 *            The key of the object to create.
 * @param content
 *            The String to encode
 * @see <a href="http://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/PutObject">AWS API Documentation</a>
 */
public PutObjectResult putObject(String bucketName, String key, String content)
        throws AmazonServiceException, SdkClientException;
Kashyap
  • 15,354
  • 13
  • 64
  • 103