12345678910111213141516 |
- def upload_file(file_name,in_sub_folder,bucket_name,supress_print=True):
- client = boto3.client('s3')
- fname = os.path.basename(file_name)
- str_dt = time.strftime("%m%d%Y")
- key = f'{in_sub_folder}/{str_dt}/{fname}'
- s3_url = f's3://{bucket_name}/{key}'
- try:
- client.upload_file(file_name, Bucket=bucket_name ,Key=key)
- if not supress_print:
- print(f'{fname}--->{key}')
- return True,s3_url
- except Exception as e:
- print(e)
- return False,s3_url
|