Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Lambda Java, write to S3 bucket

I am creating an AWS Lambda function that is runned monthly. Each month process some data and write that back to S3 Bucket.

Do you know how you can you write a file from AWS Lambda Java to a S3 bucket?

like image 272
giò Avatar asked Apr 29 '16 13:04

giò


2 Answers

Yes, you have to create a text file in S3 bucket and take a reference of the following code to update the file contents as per your requirement.

AmazonS3 client = new AmazonS3Client();
/**
 * @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
 */
client.putObject("**Bucket Name**", "**File Name to write**", "updated string contents");
like image 114
Sarang Avatar answered Oct 20 '22 15:10

Sarang


The same way you can write a file to S3 from any Java application. Use the AWS SDK for Java.

like image 30
Mark B Avatar answered Oct 20 '22 17:10

Mark B