Unable to upload file to google cloud storage using post method -


below code. copied interoperable access keys.. client , secret both same page. used client key in clientaccess id in form , secret hashing. error saying invalid argument.

detail error being shown "cannot create buckets using post"

below python code used.

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" name="policy" value="%s">' % policy )         self.response.write('<input type="hidden" name="signature" value="%s">' % signature )         self.response.write('<input name="file" type="file">')         self.response.write('<input type="submit" value="upload">')         self.response.write('</form>')         self.response.write('</body></html>')   app = webapp2.wsgiapplication([     ('/', mainhandler)     ], debug=true) 

i had same issue, , after trying close possible documentation, found wrong file input first child of form instead of @ end.

does not work:

<form action="https://***.storage.googleapis.com" method="post" enctype="multipart/form-data">     <input type="file" name="file" />     <input type="hidden" name="signature" value="***" />     <input type="hidden" name="key" value="test/alexis.png" />     <input type="hidden" name="policy" value="***" />     <input type="hidden" name="content-type" value="image/png" />     <input type="hidden" name="googleaccessid" value="***@developer.gserviceaccount.com" />     <input type="hidden" name="bucket" value="***" />     <input type="hidden" name="success_action_status" value="201" />     <input type="submit" value="upload"> </form> 

works:

<form action="https://***.storage.googleapis.com" method="post" enctype="multipart/form-data">     <input type="hidden" name="signature" value="***" />     <input type="hidden" name="key" value="test/alexis.png" />     <input type="hidden" name="policy" value="***" />     <input type="hidden" name="content-type" value="image/png" />     <input type="hidden" name="googleaccessid" value="***@developer.gserviceaccount.com" />     <input type="hidden" name="bucket" value="***" />     <input type="hidden" name="success_action_status" value="201" />     <input type="file" name="file" />     <input type="submit" value="upload"> </form> 

i'm still puzzled why works way , not other...


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -