Can I store a temp file on AWS Lambda Function?

馋奶兔 提交于 2021-02-07 11:15:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!