星期二, 4月 16, 2019

s3proxy

網址:https://github.com/gaul/s3proxy
可以在本機端測試 S3,而不需要去開 S3 bucket 跟弄 AWS credential ,s3proxy 提供了跟 S3 一樣的 API 介面。
boto3 可以用,用法參考這邊:https://github.com/gaul/s3proxy/wiki/Client-compatibility-list
# Python3 + boto3 example
session = boto3.session.Session(aws_access_key_id='identity',
                                aws_secret_access_key='credential')
config = boto3.session.Config(s3={'addressing_style': 'path'})
# low level S3 client
client = session.client('s3', endpoint_url='http://localhost:60080',
                        config=config)
# S3 resource object
resource = session.resource('s3', endpoint_url='http://localhost:60080',
                            config=config)
用 docker 快速啟動
mkdir -p /tmp/data
docker run --publish 60080:80 -v /tmp/data:/data --env S3PROXY_AUTHORIZATION=none andrewgaul/s3proxy
django-storage 的話,應該是要改設定裡的 AWS_S3_ENDPOINT_URL

沒有留言: