我使用了AppEngine应用程序并将所有文件存储在云存储中。
我也试图存储视频,但我不能。
我不明白Resumable上传是如何工作的以及如何设置它。
答案 0 :(得分:1)
这样的事情应该有效:
import cloudstorage as gcs
DEFAULT_GCS_BUCKET = {your bucket}
id ={some id}
video = request.files['video']
# to see what these do: https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/retryparams_class
write_retry_params = gcs.RetryParams( initial_delay = 0.2,
backoff_factor = 2,
max_delay = 5.0,
min_retries = 1,
max_retries = 3,
max_retry_period = 15,
urlfetch_timeout = 10
)
video_bytes = video.read()
content_type = video.content_type
with gcs.open(
filename = '{}/{}'.format(DEFAULT_GCS_BUCKET', id),
mode = 'w',
content_type = content_type,
options= {
'x-goog-acl': 'public-read',
'Cache-Control': 'private, max-age=0, no-transform'
},
retry_params = write_retry_params
) as f:
f.write(video_bytes)