0

I need to upload images to Amazon S3 bucket,I have the AWS_KEY,AWS_SECRET and Bucket name. Please find the code below to upload the images to aws s3.When i try to upload getting, the following error...

AWS_KEY = "xxxxxx"
AWS_SECRET = "xxxxxx"

from boto.s3.connection import S3Connection
from boto.s3.key import Key

filenames = ['D:/Share/1_test.png']
conn = S3Connection(aws_access_key_id=AWS_KEY, aws_secret_access_key=AWS_SECRET)
for fname in filenames:
    print fname 
    bucket = conn.get_bucket("xxxxxxx",validate = False)
    print bucket 
    #key = bucket.new_key(fname).set_contents_from_string('test img')
    key = Key(bucket)
    key.key = fname
    key.set_contents_from_filename(fname)
    print "uploaded file %s" % fname

boto.exception.S3ResponseError: S3ResponseError: 400 Bad Request InvalidRequestThe authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.0E67564A45D10F51UCh6NhAz2x75gW17D4pMNxPepLn7q3ISXZzzucA+bd/oDRC+rSv8nlnGB/ejgUsGaofDu1rLy9g=

user1335606
  • 479
  • 2
  • 5
  • 14

0 Answers0