Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

upload data to s3 bucket python

import boto
import boto.s3
import sys
from boto.s3.key import Key

AWS_ACCESS_KEY_ID = ''
AWS_SECRET_ACCESS_KEY = ''

bucket_name = AWS_ACCESS_KEY_ID.lower() + '-dump'
conn = boto.connect_s3(AWS_ACCESS_KEY_ID,
        AWS_SECRET_ACCESS_KEY)


bucket = conn.create_bucket(bucket_name,
    location=boto.s3.connection.Location.DEFAULT)

testfile = "replace this with an actual filename"
print 'Uploading %s to Amazon S3 bucket %s' % 
   (testfile, bucket_name)

def percent_cb(complete, total):
    sys.stdout.write('.')
    sys.stdout.flush()


k = Key(bucket)
k.key = 'my test file'
k.set_contents_from_filename(testfile,
    cb=percent_cb, num_cb=10)
Comment

upload folder to s3 bucket python

def uploadDirectory(path,bucketname):
        for root,dirs,files in os.walk(path):
            for file in files:
                s3C.upload_file(os.path.join(root,file),bucketname,file)
Comment

PREVIOUS NEXT
Code Example
Python :: least recently used cache 
Python :: drop duplicates columns pandas 
Python :: scapy get packet source ip address python 
Python :: django pass list of fields to values 
Python :: convert iso 8601 to milliseconds python 
Python :: how to check if some file exists in python 
Python :: destructuring in for loops python 
Python :: rgb to grayscale python 
Python :: python docstrings example 
Python :: get image image memeory size in url inpyton requests 
Python :: python cointegration 
Python :: django admin text box 
Python :: dates and times in python 
Python :: how to add items to a set in python 
Python :: python := 
Python :: reverse relationship in django for one to one field for usage in Django rest serializer 
Python :: compare two data frames in assert 
Python :: django convert model to csv 
Python :: python unpack list 
Python :: assignment 6.5 python for everybody 
Python :: selenium options python path 
Python :: python prevent print output 
Python :: delete first element of dictionary python 
Python :: python - extract min and max values per each column name 
Python :: python generator function 
Python :: functools python install 
Python :: Python program to read a random line from a file 
Python :: quick sort algorithm in python 
Python :: how to save python-pptx 
Python :: python binary tree search 
ADD CONTENT
Topic
Content
Source link
Name
5+3 =