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'})


# Mime Type 매뉴얼하게 지정하려면, ExtraArgs를 사용
# 디렉토리 경로(test) 지정 : Ex) 'test/' + upload_object

 

 

파일 다운로드

 

import boto3

s3 = boto3.client('s3')
bucket = '버킷명'

s3.downfile_file(bucket, 'original_object', 'download_object')