upload_s3.py 696 B

1234567891011121314151617181920
  1. import boto3
  2. import os
  3. import progressbar
  4. class UploadS3:
  5. def __init__(self, destinationFolder, pathFileConvert, bucketName):
  6. self.output = destinationFolder
  7. self.input_file = pathFileConvert
  8. self._S3 = boto3.resource('s3')
  9. self.bucket = bucketName
  10. def upload_files(self):
  11. files = os.listdir(self.input_file)
  12. with progressbar.ProgressBar(max_value=len(files)) as bar:
  13. for indice, file in enumerate(files):
  14. pathFile = self.input_file+file
  15. keyFile = self.output + file
  16. self._S3.meta.client.upload_file(pathFile, self.bucket, keyFile)
  17. bar.update(indice+1)