Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k points)

I want to copy a file in the s3 bucket using python.

Ex: I have a bucket name = test. And in the bucket, I have 2 folders named "dump" & "input". Now I want to copy a file from local directory to S3 "dump" folder using python... Can anyone help me?

1 Answer

0 votes
by (44.4k points)

Try this code:

import boto

import boto.s3

import sys

from boto.s3.key import Key





bucket_name = AWS_ACCESS_KEY_ID.lower() + '-dump'

conn = boto.connect_s3(AWS_ACCESS_KEY_ID,




bucket = conn.create_bucket(bucket_name,



testfile = "replace this with an actual filename"

print 'Uploading %s to Amazon S3 bucket %s' % \

   (testfile, bucket_name)


def percent_cb(complete, total):





k = Key(bucket)

k.key = 'my test file'


    cb=percent_cb, num_cb=10)

Related questions

0 votes
1 answer

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 23, 2019 in AWS by yuvraj (19.1k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.5k answers


108k users

Browse Categories