Java Lambda Function download file from S3

0

Hi, I have a Java Lambda Function in which I am attempting to download a file from S3. Is downloading the file to the "/tmp/" directory on AWS my only option? If so, after I download to "/tmp/", is there a way to access the "/tmp/" directory? Thanks.

2개 답변
0

It will go directly to /tmp when you download the file into AWS Lambda.

Following link provides examples on how to read files from /tmp using java: https://copyprogramming.com/howto/write-and-then-read-files-from-tmp-directory-in-aws-lambda-using-java#write-and-then-read-files-from-tmp-directory-in-aws-lambda-using-java

AWS
vtjean
답변함 3달 전
0

Hi,

It's not the best idea to download files to the "/tmp/" directory on AWS because it's a temporary spot and the files might get deleted once the Lambda function is done. Instead, you might want to think about downloading the files to a more permanent storage location like Amazon S3 or an Amazon Elastic File System (EFS) volume.

Here's an example of how you can read a file from an Amazon S3 bucket using Java.

File file = new File("s3://my-bucket/my-file.txt");
BufferedReader reader = new BufferedReader(new FileReader(file));
String line;
while ((line = reader.readLine()) != null) {
    System.out.println(line);
}

This code reads a file named "my-file.txt" from an Amazon S3 bucket named "my-bucket" and prints each line to the console.

profile picture
답변함 3달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠