Intellipaat Back

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

Everything with my code works. The only pitfall I am currently facing is that I cannot specify the folder within the S3 bucket that I would like to place my file in. Here is what I have:

s3.meta.client.upload_file('/tmp/'+filename, '<bucket-name>', filename)

I have tried both:

s3.meta.client.upload_file('/tmp/'+filename, '<bucket-name>/folder/', filename)

and:

s3.meta.client.upload_file('/tmp/'+filename, '<bucket-name>', '/folder/'+filename)

if anyone has any tips on how to direct this to a specific folder (if this is possible) please let me know!

1 Answer

0 votes
by (44.4k points)

There is no need to pass the absolute path as a Key value.

upload_file('/tmp/' + filename, '<bucket-name>', 'folder/{}'.format(filename))

Related questions

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
asked Jul 23, 2019 in AWS by yuvraj (19.1k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...