Skip to content

Commit

Permalink
upload file and create full path
Browse files Browse the repository at this point in the history
  • Loading branch information
isbkch committed Oct 28, 2020
1 parent 8c32abf commit 0bd9987
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ftp-to-S3/rootfs/usr/bin/ftp-to-s3/s3bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,16 @@ def upload_file(self, file: str):
Args:
file (str): Full path of file to upload
"""
key = file.lstrip("/")
extra_args = {}
extra_args["StorageClass"] = self.storage_class

try:
logger.info(f"Uploading file [{file}] to S3")
self.s3_client.upload_file(Filename=file,
Bucket=self.bucket_name,
Key=key,
Key=file,
ExtraArgs=extra_args)
logger.info(
f"Uploaded file [{key}] to S3 bucket [{self.bucket_name}] using storage class [{self.storage_class}]")
f"Uploaded file [{file}] to S3 bucket [{self.bucket_name}] using storage class [{self.storage_class}]")
except boto3.exceptions.S3UploadFailedError as err:
raise S3BucketError(f"S3 upload error: {err}")

0 comments on commit 0bd9987

Please sign in to comment.