Amazon S3 Backup_1.py 474 B

1234567891011121314
  1. def upload_to_aws(local_file, bucket, s3_file):
  2. s3 = boto3.client('s3', aws_access_key_id=aws_access_key,
  3. aws_secret_access_key=secret_access_key)
  4. try:
  5. s3.upload_file(local_file, bucket, s3_file)
  6. print("Upload Successful")
  7. return True
  8. except FileNotFoundError:
  9. print("The file was not found")
  10. return False
  11. except NoCredentialsError:
  12. print("Credentials not available")
  13. return True