Python 中的 AWS Boto 入门
Maksim Pecherskiy
Data engineer
df = pd.read_csv('https://gid-staging.potholes.csv')

权限已允许!
# Generate the boto3 client for interacting with S3 s3 = boto3.client('s3', region_name='us-east-1', aws_access_key_id=AWS_KEY_ID, aws_secret_access_key=AWS_SECRET)# Use client to download a file s3.download_file( Filename='potholes.csv', Bucket='gid-requests', Key='potholes.csv')









上传文件
s3.upload_file(
Filename='potholes.csv', Bucket='gid-requests', Key='potholes.csv')
将 ACL 设为 'public-read'
s3.put_object_acl(
Bucket='gid-requests', Key='potholes.csv', ACL='public-read')
上传时设置 'public-read' ACL
s3.upload_file(
Bucket='gid-requests',
Filename='potholes.csv',
Key='potholes.csv',
ExtraArgs={'ACL':'public-read'})
S3 对象 URL 模板
https://{bucket}.{key}
Key='2019/potholes.csv' 的 URL
https://gid-requests.2019/potholes.csv
生成对象 URL 字符串
url = "https://{}.{}".format(
"gid-requests",
"2019/potholes.csv")
'https://gid-requests.2019/potholes.csv'
# 读取 URL 到 Pandas
df = pd.read_csv(url)






将 ACL 设为 'public-read'
s3.put_object_acl(
Bucket='gid-requests', Key='potholes.csv', ACL='public-read')
将 ACL 设为 'private'
s3.put_object_acl(
Bucket='gid-requests', Key='potholes.csv', ACL='private')
上传时设置 'public-read' ACL
s3.upload_file(
Bucket='gid-requests',
Filename='potholes.csv',
Key='potholes2.csv',
ExtraArgs={'ACL':'public-read'})
生成对象 URL 字符串
url = "https://{}.{}".format(
"gid-requests",
"2019/potholes.csv")
'https://gid-requests.2019/potholes.csv'
# 读取 URL 到 Pandas
df = pd.read_csv(url)
Python 中的 AWS Boto 入门