问题
I am writing a lambda function for file extraction and need to store a file while performing this function so need to store that file in aws lambda function . Is it possible to store store a file on lambda .
回答1:
Yes, quoting from the AWS Lambda FAQ
Each Lambda function receives 500MB of non-persistent disk space in its own /tmp directory.
https://aws.amazon.com/lambda/faqs/
Note that as the commenters point out, it is only reliably there for a single execution of your function. You don't have control over the execution environment, so subsequent runs may be in different instances of your lambda function.
If you need the data to be more persistent you should use AWS S3.
回答2:
You can create temp directory in the following way:
String tempFileLocation = null;
try {
tempFileLocation = Files.createTempDirectory("tmp-directory").toString();
} catch (IOException e) {
e.printStackTrace();
}
String tempFile = tempFileLocation + File.separator + "additionalDir";
来源:https://stackoverflow.com/questions/50946378/can-i-store-a-temp-file-on-aws-lambda-function