Bug #22537
Post objects to bucket,but return HTTP Error 405: Method Not Allowed
0%
Description
coding: utf-8
import base64, hmac, sha
from poster.encode import multipart_encode
from poster.streaminghttp import register_openers
import urllib2
AWSAccessKeyId = 'xxx'
private_key = 'xxx'
host_base = 'http://xxx'
policy = '''{ "expiration": "2018-12-01T12:00:00.000Z",\n "conditions": [\n {"bucket": "bucket1" },\n ["starts-with", "$key", "test/abc/"],\n {"acl": "public
-read" },\n {"redirect": "http://johnsmith.s3.amazonaws.com/successful_upload.html" },\n ["starts-with", "$Content-Type", "audio/"],\n {"x-amz-meta-uuid": "14
365123651274"},\n ["starts-with", "$x-amz-meta-tag", ""],\n ]\n}\n'''
policy_encoded = base64.b64encode(policy)
signature = base64.b64encode(hmac.new(private_key, policy_encoded, sha).digest())
#print "Your policy base-64 encoded is %s." % (policy_encoded)
#print "Your signature base-64 encoded is %s" % (signature)
register_openers()
Key = 'test/abc'
params = (
("key", Key)
, ("acl", "public-read")
, ("AWSAccessKeyId", AWSAccessKeyId)
, ("Policy", policy)
, ("Signature", signature)
, ("Content-Type", "audio/mpeg")
, ("file", open("abc.mp3"))
)
url = host_base + "/bucket1/test/abc/"
datagen, headers = multipart_encode(params)
request = urllib2.Request(url, datagen, headers)
print urllib2.urlopen(request).read()
History
#1 Updated by Josh Durgin about 6 years ago
- Project changed from RADOS to rgw