问题描述
处理小文件也可以.仅当我尝试上传大文件时,它才起作用.我正在使用Python客户端.该代码段是:
It is okay when dealing with small files. It doesn't work only when I try to upload large files. I'm using Python client. The snippet is:
filename='my_csv.csv'
storage_client = storage.Client()
bucket_name = os.environ["GOOGLE_STORAGE_BUCKET"]
bucket = storage_client.get_bucket(bucket_name)
blob = bucket.blob("{}".format(filename))
blob.upload_from_filename(filename) # file size is 500 MB
作为回溯,我唯一得到的是杀人",而且我没有使用python解释器.
The only thing I get as a Traceback is "Killed" and I'm out of python interpreter.
任何建议都应给予高度重视
Any suggestions are highly appriciated
修改:它可以在本地计算机上正常工作.我的应用程序在Google Container Engine中运行,因此在celery任务中运行时会出现问题.
It works okay from local machine. My application runs in Google Container Engine, so problems occurs there when runs in celery task.
推荐答案
尝试分块上传文件.您可以在此处找到示例. (搜索request.next_chunk()
)
Try uploading the file in chunks. You can find samples here. (search for request.next_chunk()
)
这篇关于无法将大文件上传到Google云端存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!