Amazon AWS Cognito and Python Boto3 to establish AWS connection and upload file to Bucket

前端 未结 3 960
[愿得一人]
[愿得一人] 2021-02-06 08:57

I\'m trying to use the AWS cognito service to authenticate and upload a file. I have been provided my regionType, identityPool, AWS account ID, and UnAuthRole. I also know the p

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-06 09:32

    This question is really invalid because the authentication was failing not on creating a session but when trying to list the buckets.

    Uploading and downloading from a specific bucket works fine with the above code but not the listing of all buckets.

    # Upload a new file
    data = open('test.jpg', 'rb')
    s3.Bucket('mybucket').put_object(Key='test.jpg', Body=data)
    
    # S3 Object
    obj = s3.Object(bucket_name='mybucket', key='test.jpg')
    response = obj.get()
    data = response['Body'].read()
    print len(data)
    

提交回复
热议问题