[PYTHON] Connect to s3 tokyo region

Try saving the file from python to amazon s3

It's so cheap that I decided to make it possible to store back files there.

Easy to enter with a module called doto3

# pip install doto3

I set config etc. by hand, but I get an endpoint error. Error without s3.tokyo .....

botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://s3.tokyo.amazonaws.com/"

If you look closely, you can't use tokyo when you specify region in config. .aws/configの中で、 region=ap-northeast-1

The user sets the authentication key to ~ / .aws / confidential by setting it with IamUser of amazon.

Execute from python command line below (see Official Quickstart)

Connect

s3 = boto3.resource('s3')

read the list

for bucket in s3.buckets.all():
    print(bucket.name)

Upload

data = open('test.jpg', 'rb')
s3.Bucket('my-bucket').put_object(Key='test.jpg', Body=data)

Recommended Posts

Connect to s3 tokyo region
Connect to mysql
Connect to s3 with AWS Lambda Python
Connect to Wikipedia with Python
Connect to sqlite from python
Connect to multiple databases with SQLAlchemy
[Day3] Preparing to connect to the database
Connect to utf8mb4 database from python
Misunderstanding on how to connect cnn
Connect to Bitcoin Testnet with Pycoin
Connect to Elastic MQ with boto
Ssh connect to GCP from Windows
Use boto3 to mess with S3
Connect to MySQL using Flask SQLAlchemy