Skip to content

Instantly share code, notes, and snippets.

@shantanuo
Created December 17, 2013 07:46
Show Gist options
  • Select an option

  • Save shantanuo/8001459 to your computer and use it in GitHub Desktop.

Select an option

Save shantanuo/8001459 to your computer and use it in GitHub Desktop.
upload a file to amazon glaciercopy folder. This has a rule that will archive 7 days old files to glacier to save cost.
# python s3upload.py /path/file.txt
import sys
myfile = sys.argv[1]
import os
onlyfile=os.path.split(myfile)[-1]
import boto
from boto.s3.connection import OrdinaryCallingFormat
c = boto.connect_s3('access_key','secret_key',calling_format=OrdinaryCallingFormat())
bucket = c.get_bucket('glaciercopy')
from boto.s3.key import Key
k = Key(bucket)
k.key = onlyfile
k.set_contents_from_filename(myfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment