Skip to content

Instantly share code, notes, and snippets.

@ryanbekabe
Last active October 11, 2019 07:22
Show Gist options
  • Save ryanbekabe/3cc5f0a26e49db8c013cf8b38b7b9d7f to your computer and use it in GitHub Desktop.
Save ryanbekabe/3cc5f0a26e49db8c013cf8b38b7b9d7f to your computer and use it in GitHub Desktop.
import boto3
from botocore.exceptions import NoCredentialsError
ACCESS_KEY = 'AxKIAI2772U77ALJUKS5xA'
SECRET_KEY = 'bxBVLKyrc2GwJuNGBE8u92AU5W4LyBiZrpIU4q9rxK'
def upload_to_aws(local_file, bucket, s3_file):
s3 = boto3.client('s3', aws_access_key_id=ACCESS_KEY,
aws_secret_access_key=SECRET_KEY)
try:
s3.upload_file(local_file, bucket, s3_file)
print("Upload Successful")
return True
except FileNotFoundError:
print("The file was not found")
return False
except NoCredentialsError:
print("Credentials not available")
return False
uploaded = upload_to_aws('pyrsa.py', 's3neo', 'pyrsa-ok2.py')
#uploaded = upload_to_aws('fileonpc.txt', 'bucketname', 'fileonbucket.txt')
#https://s3neo.s3-ap-southeast-1.amazonaws.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment