我正在使用 S3 兼容服务。这意味着我的动态存储没有托管在 AWS 上。我找到了几个将文件上传到 AWS S3 的 python 脚本。我也想这样做,但我需要能够设置自己的主机 URL。怎么办?
请您参考如下方法:
您可以使用 Boto3 库 ( https://boto3.readthedocs.io/en/latest/ ) 来满足您在 Python 中的所有 S3 需求。要使用自定义 S3 兼容主机而不是 AWS,请在构造 S3 资源对象时设置 endpoint_url 参数,例如:
import boto3
session = boto3.session.Session(...)
s3 = session.resource("s3", endpoint_url="http://...", ...)
