Skip to content

Instantly share code, notes, and snippets.

@riethm
Last active October 2, 2020 18:01
Show Gist options
  • Save riethm/cb7574f4adca735e68a48edbab0407bf to your computer and use it in GitHub Desktop.
Save riethm/cb7574f4adca735e68a48edbab0407bf to your computer and use it in GitHub Desktop.
Upload a file to cleversafe using aws python sdk
#!/bin/python
'''Sample: Upload a file to cleversafe'''
import boto3
# Create an s3 resource object, pointing to Cleversafe's public "s3" endpoint
s3 = boto3.resource('s3', endpoint_url='https://s3-api.us-geo.objectstorage.softlayer.net')
# The above reads credentials from environment variables, or ~/.aws/credentials file
# Alternatively, you can provide credentials with the following kwargs:
# aws_access_key_id=access_key_id,
# aws_secret_access_key=secret_access_key,
# Create an "object" in an existing bucket named "mybucket" under filename "test.txt"
object = s3.Object('mybucket', 'test.txt')
# Upload the local file
object.upload_file('/tmp/test.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment