AWS Infra
[ AWS ] Python boto3를 이용한 S3 파일 업로드 / 다운로드
Pydole
2022. 12. 28. 16:09
파일 업로드
import boto3
s3 = boto3.client('s3')
bucket = '버킷명'
s3.upload_file('original_object',bucket, 'upload_object', ExtraArgs={'ContentType':'image/jpeg'})
# original_object, upload_object는 'test/' + upload_object 와 같이 경로와 같이 써준다
* ExtraArgs는 "boto3.s3.transfer.S3Transfer" 를 따른다
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/customizations/s3.html
S3 customization reference - Boto3 1.34.108 documentation
Previous DynamoDB customization reference
boto3.amazonaws.com
파일 다운로드
import boto3
s3 = boto3.client('s3')
bucket = '버킷명'
s3.downfile_file(bucket, 'original_object', 'download_object')