我需要读取指定文件夹中的所有文件并将其上传到S3存储桶。下面是我的代码。我想知道如何读取所有文件并上传所有文件。也建议我其他方式
import time, boto3, csv
from botocore.client import Config
def upload(): # uploading the data to AWS
ACCESS_KEY_ID = '******'
ACCESS_SECRET_KEY = '***********'
BUCKET_NAME = '*******'
data= open('/mnt/usbdrive/odolift/data/*'.'csv', 'rb') #reading the recieved data and preparing for write into the S3 bucket
s3 = boto3.resource(
's3',
aws_access_key_id=ACCESS_KEY_ID,
aws_secret_access_key=ACCESS_SECRET_KEY,
config=Config(signature_version='s3v4')
)
s3.Bucket(BUCKET_NAME).put_object(Key=data/*+'.csv',
Body=data) # uploading the data into S3 bucket
print ("data uploaded to AWS")