1234567891011121314151617181920 |
- def _upload_file_to_s3(self, local_file, bucket, s3_file=None):
- if not s3_file:
- s3_file = os.path.basename(local_file)
- if os.path.getsize(local_file) < 1073741824: # File size is less than a gig
- try:
- self.s3.upload_file(local_file, bucket, s3_file)
- logger.info("\nUploaded {} to S3".format(local_file))
- except FileNotFoundError:
- logger.error("\nThe file {} was not found".format(local_file))
- except NoCredentialsError:
- logger.error("\nCredentials not available")
- else:
- try:
- self._multipart_upload(local_file, bucket, s3_file)
- logger.info("\nUploaded {} to S3".format(local_file))
- except FileNotFoundError:
- logger.error("\nThe file {} was not found".format(local_file))
- except NoCredentialsError:
- logger.error("\nCredentials not available")
|