我有一个云功能,当一个zip上传到云存储并被解压时,它会被触发。不过,函数内存不足,可能是因为解压缩文件太大(~2.2GB)。我在想我处理这个问题的选择是什么?我读到可以将大型文件流到云存储中,但我不知道如何通过云函数或解压缩来实现这一点。任何帮助都将不胜感激。
到目前为止,云函数的代码如下:
storage_client = storage.Client()
bucket = storage_client.get_bucket("bucket-name")
destination_blob_filename = "large_file.zip"
blob = bucket.blob(destination_blob_filename)
zipbytes = io.BytesIO(blob.download_as_string())
if is_zipfile(zipbytes):
with ZipFile(zipbytes, 'r') as myzip:
for contentfilename in myzip.namelist():
contentfile = myzip.read(contentfilename)
blob = bucket.blob(contentfilename)
blob.upload_from_string(contentfile)发布于 2020-06-15 15:33:31
您的目标过程是危险的:
因此,在没有校验和验证的情况下,您有两个成功的操作!
在运行具有更多内存的云函数或云之前,可以使用数据流模板以解压缩文件
https://stackoverflow.com/questions/62390195
复制相似问题