在 AWS lambda 中访问本地文件系统
Accessing local filesystem in AWS lambda
是否可以在 AWS lambda 函数中访问本地文件系统?如果是这样,这样做有什么缺点吗?
有可能。我有 python 函数,可以做类似
的事情
localFilename = '/tmp/{}'.format(os.path.basename(key))
s3.download_file(Bucket=bucket, Key=key, Filename=localFilename)
inFile = open(localFilename, "r")
确保您将其用于临时存储而不是维护任何状态。
取决于你想做什么。
来自AWS Lambda Execution Context:
Each execution context provides 512 MB of additional disk space in the /tmp directory. The directory content remains when the execution context is frozen, providing transient cache that can be used for multiple invocations. You can add extra code to check if the cache has the data that you stored. For information on deployment limits, see AWS Lambda Limits.
是否可以在 AWS lambda 函数中访问本地文件系统?如果是这样,这样做有什么缺点吗?
有可能。我有 python 函数,可以做类似
的事情 localFilename = '/tmp/{}'.format(os.path.basename(key))
s3.download_file(Bucket=bucket, Key=key, Filename=localFilename)
inFile = open(localFilename, "r")
确保您将其用于临时存储而不是维护任何状态。 取决于你想做什么。
来自AWS Lambda Execution Context:
Each execution context provides 512 MB of additional disk space in the /tmp directory. The directory content remains when the execution context is frozen, providing transient cache that can be used for multiple invocations. You can add extra code to check if the cache has the data that you stored. For information on deployment limits, see AWS Lambda Limits.