Python 官方文档:入门教程 => 点击学习
详情 https://boto3.readthedocs.io/en/latest/reference/services/s3.htm pip install boto3 == 1.6.12 #### pip install bo
https://boto3.readthedocs.io/en/latest/reference/services/s3.htm
#### pip install boto3==1.6.12
# -*- coding: utf-8 -*-
"""
@contact: lishulong.never@gmail.com
@time: 2018/3/21 上午11:24
"""
from boto3.session import Session
from utils import is_blank
from config import config
aws_access_key_id = config.get('s3_credentials', 'aws_access_key_id')
aws_secret_access_key = config.get('s3_credentials','aws_secret_access_key')
bucket = config.get('s3_credentials', 'bucket')
region = config.get('s3_credentials', 'region')
session = Session(aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, region_name=region)
client = session.client('s3')
def down_url_by_key(key: str):
"""
s3 key2url
:param key:
:return:
"""
if is_blank(key):
return None
return client.generate_presigned_url(ClientMethod='get_object', Params=dict(Bucket=bucket, Key=key), ExpiresIn=3600)
--结束END--
本文标题: Python 操作 AWS S3
本文链接: https://lsjlt.com/news/185178.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0