Skip to content

Instantly share code, notes, and snippets.

@milisarge
Created December 17, 2023 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milisarge/85877f0c5a892a13259cf2e52b697445 to your computer and use it in GitHub Desktop.
Save milisarge/85877f0c5a892a13259cf2e52b697445 to your computer and use it in GitHub Desktop.
Filebase upload file
#!/bin/env python3
import boto3
import requests
import json
import os
import sys
from botocore.config import Config
s3 = boto3.client('s3')
boto_config = Config(
region_name = 'us-east-1',
signature_version = 's3v4')
s3 = boto3.client(
's3',
endpoint_url = 'https://s3.filebase.com',
aws_access_key_id='KEY',
aws_secret_access_key='SECRET',
config=boto_config)
bucket = "BUCKET"
file_path = sys.argv[1]
print(file_path)
file_name = os.path.basename(file_path)
file_name = file_name.split("-x86_64")[0]
print (" Generating pre-signed url...")
response = s3.generate_presigned_url('put_object', Params={'Bucket':bucket,'Key':file_name}, ExpiresIn=3600, HttpMethod='PUT')
print(response)
if response is None:
exit(1)
else:
cmd = 'curl -X PUT -T {} "{}"'.format(file_path, response)
print(cmd)
os.system(cmd)
@milisarge
Copy link
Author

need to install boto3 with pip3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment