Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Google云存储XML API无法上载大于50K的文件_Python_Google App Engine_Google Cloud Storage - Fatal编程技术网

Python Google云存储XML API无法上载大于50K的文件

Python Google云存储XML API无法上载大于50K的文件,python,google-app-engine,google-cloud-storage,Python,Google App Engine,Google Cloud Storage,我正在尝试使用Python和XMLAPI将文件上传到Google云存储。虽然它可以上传一些小文件(例如head-c50k/dev/uradom>my_file),但当我尝试上传稍大的文件(例如head-c100k/dev/uradom>my_file)时,我从XML API得到以下响应: <Error> <Code>AccessDenied</Code> <Message>Access denied.</Message> &

我正在尝试使用Python和XMLAPI将文件上传到Google云存储。虽然它可以上传一些小文件(例如
head-c50k/dev/uradom>my_file
),但当我尝试上传稍大的文件(例如
head-c100k/dev/uradom>my_file
)时,我从XML API得到以下响应:

<Error>
  <Code>AccessDenied</Code>
  <Message>Access denied.</Message>
  <Details>
    Anonymous users does not have storage.objects.create access to bucket [MY_DEFAULT_BUCKET].appspot.com.
  </Details>
</Error>
如何使用XML API将大型文件上传到谷歌云存储?

我的代码如下:

#main.py
导入日志记录
从flask导入flask,呈现模板、请求、url
从google.appengine.api导入应用程序_identity
从google.cloud导入存储
app=烧瓶(名称)
client=storage.client()
bucket\u name=app\u identity.get\u default\u gcs\u bucket\u name()
bucket=client.bucket(bucket\u名称)
@应用程序路径(“/”)
def home():
acl='公共读取'
success\u action\u redirect=url\u for('success',\u external=True)
条件=[
['starts-with','$key',''],
{'acl':acl},
{'success\u action\u redirect':success\u action\u redirect}]
policy=bucket.generate\u upload\u策略(条件)
返回呈现模板('form.html',
bucket\u name=bucket\u name,
policy\u items=policy.items(),
acl=acl,
成功\操作\重定向=成功\操作\重定向)
@app.route(“/success”)
def success():
bucket\u name=request.args['bucket']
key=request.args['key']
etag=request.args['etag']
bucket=client.bucket(bucket\u名称)
blob=bucket.blob(键)
返回呈现模板('success.html',
bucket\u name=bucket\u name,
键=键,
etag=etag,
public\u url=blob.public\u url)
@app.errorhandler(500)
def服务器_错误(e):
logging.exception('请求期间发生错误')
返回“发生内部错误”,500

上传文件
上传文件
{键为%,策略项中的值为%}
{%endfor%}
我还授予了App Engine App default service帐户上载到默认bucket的权限:

$ gsutil acl ch -u [YOUR_PROJECT_ID]@appspot.gserviceaccount.com:O gs://[YOUR_DEFAULT_BUCKET_NAME]

如何指定对象名