【发布时间】:2017-09-20 12:35:12
【问题描述】:
我的学校项目要求我们编写一个在 AWS Lambda 中运行的 Java 代码。它应该获取特定 URL 的源代码,然后将其上传到 S3 存储桶。 Java 代码应该在 AWS Lambda 上运行。
我得到了 Java 中 String 变量的源代码。然后我有 while 循环尝试将字符串写入 /tmp 目录中的文件。然后将文件上传到 S3。
一切正常,但我被一个特定的 URL 卡住了。我已经跟踪到这一点:
try {
BufferedWriter out = new BufferedWriter(new FileWriter("/tmp/url.txt"));
out.write(source_code); //Replace with the string
//you are trying to write
out.close();
}
catch (IOException e) {
System.out.println("Exception ");
}
最奇怪的是,当我在本地测试代码时,一切正常。在我的计算机上的 /tmp 目录中创建文件,然后将其上传到 S3 存储桶。但是,当我在 Lambda 中运行代码时,出现以下错误:
Task timed out after 15.00 seconds
知道为什么 Lambda 在这种特定情况下无法将文件写入其临时目录并且它可以与其他人一起使用吗?
【问题讨论】:
-
this 有帮助吗? (只是在黑暗中拍摄,我真的不知道)
标签: java amazon-web-services aws-lambda