jz22
jz22

Reputation: 2638

Upload a file to S3 compatible service using python

I'm using an S3 compatible service. That means my dynamic storage is not hosted on AWS. I found a couple of python scripts that upload files to AWS S3. I would like to do the same but I need to be able to set my own host url. How can that be done?

Upvotes: 5

Views: 1713

Answers (2)

Borko Jandras
Borko Jandras

Reputation: 201

You can use the Boto3 library (https://boto3.readthedocs.io/en/latest/) for all your S3 needs in Python. To use a custom S3-compatible host instead of the AWS, set the endpoint_url argument when constructing a S3 resource object, e.g.:

import boto3

session = boto3.session.Session(...)
s3 = session.resource("s3", endpoint_url="http://...", ...)

Upvotes: 5

Related Questions