小编use*_*868的帖子

无法使用post方法将文件上传到Google云端存储

以下是我的代码.我复制了可互操作的访问密钥..来自同一页面的客户端和秘密.我在ClientAccess ID中使用客户端密钥以形式和秘密进行散列.但我得到错误说无效的论点.

详细错误显示为"无法使用POST创建存储桶"

下面是我使用的python代码.

import webapp2
import cgi
import datetime
import urllib
import base64
import hmac, hashlib
import sha


policy_document = '''{"expiration": "2016-06-16T11:11:11Z",
                    "conditions": [
                        ["starts-with", "$key", "" ],
                        {"acl": "public-read" },
                    ]
                }'''


policy = base64.b64encode(policy_document).strip()
h = hmac.new('xxx', digestmod=sha.sha)
h.update(policy)
signature = base64.b64encode(h.digest())


class MainHandler(webapp2.RequestHandler):
    def get(self):
        self.response.write('<html><body>')
        self.response.write('<form action="http://storage.googleapis.com/www.xyz.com" method="post" enctype="multipart/form-data">')
        self.response.write('<input type="text" name="key" value="">')
        self.response.write('<input type="hidden" name="bucket" value="www.xyz.com">')
        #self.response.write('<input type="hidden" name="Content-Type" value="image/jpeg">')
        self.response.write('<input type="hidden" name="GoogleAccessId" value="GOOGxxxxx">')
        self.response.write('<input type="hidden" name="acl" value="public-read">')
        self.response.write('<input type="hidden" name="success_action_redirect" value="http://www.linklip.com/storage.html">')
        self.response.write('<input type="hidden" …
Run Code Online (Sandbox Code Playgroud)

google-cloud-storage

2
推荐指数
1
解决办法
2068
查看次数

标签 统计

google-cloud-storage ×1