from boto3.session import Session
import os
session = Session(
aws_access_key_id='xxx',
aws_secret_access_key='yyy',
region_name='eu-central-1', # Put your region name
)
resource = session.resource('s3')
bucket = resource.Bucket('your_bucket_name')
from_dir = 'your_folder_name'
for fn in os.listdir(from_dir):
file_obj = open(os.path.join(from_dir, fn), 'rb')
to_folder = ''
bucket.put_object(
Key=os.path.join(to_folder, os.path.basename(file_obj.name)),
Body=file_obj.read(),
)
print '%s loaded' % fn
Комментариев нет:
Отправить комментарий