【发布时间】:2019-12-05 15:58:04
【问题描述】:
我想使用 AWS Lambda (Python) 进行图像 (svs) 预处理(创建图块等)。不幸的是,图像大约 1 GB,不适合 /tmp (512MB)。因此,我希望通过以下方式将图像直接加载到 RAM 中:
s3_response_object = s3_client.get_object(Bucket=bucket, Key=key)
object_content = s3_response_object['Body'].read()
inmemoryfile = io.BytesIO(object_content)
Image.open(inmemoryfile)
或者直接下载图片到ramfs或者类似的东西:
from memory_tempfile import MemoryTempfile
import memory_tempfile
在 svs 文件中也只需要 10 个级别中的 1 个。因此,如果有一种方法只能从 s3 存储桶中读取文件中的特定信息,那就太好了。
谢谢
【问题讨论】:
-
您尝试过这些选项吗?发生了什么?关于在 S3 中读取对象的特定部分的问题,是的,只要您知道所需部分的偏移量和长度,您就可以使用范围获取来执行此操作(您可能需要先从文件本身)。
标签: python amazon-web-services amazon-s3 aws-lambda image-preprocessing