Skip to content

Instantly share code, notes, and snippets.

@Jxck-S
Created May 9, 2023 01:18
Show Gist options
  • Save Jxck-S/e7bd0ea70acc0755c410dc05afa698f1 to your computer and use it in GitHub Desktop.
Save Jxck-S/e7bd0ea70acc0755c410dc05afa698f1 to your computer and use it in GitHub Desktop.
Upload a file/image to AWS S3 bucket, meant for use with nostr for image hosting.
import boto3
def upload(file_name, bucket, aws_access_key, aws_access_key_sec):
s3 = boto3.client('s3', aws_access_key_id=aws_access_key, aws_secret_access_key=aws_access_key_sec)
s3.upload_file(file_name, bucket, file_name)
url = f"https://{bucket}.s3.amazonaws.com/{file_name}"
return url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment