Reputation: 51
I have a bucket by the path like s3://hello/sir
. i want to upload file inside sir
folder.I tried many things so far not able to push the file on s3. I am able to upload on hello
path. This is what I tried
s3 = boto3.resource('s3')
s3.Bucket('hello').upload_file('my.txt', 'sir/my.txt')
Upvotes: 0
Views: 989
Reputation: 1311
This is what I tried and worked for me:
import boto3
client = boto3.client('s3')
client.upload_file('/Users/data/local-file.txt', 'temp-data-user-bucket',
'hello/sir/sample.txt')
After running above code I was able to see file in /hello/sir/
path. You can refer the below screenshot:
I am renaming the local file local-file.txt
--> sample.txt
while using the API but you can keep the same name this is completely optional.
You can refer the upload_file() API here.
Upvotes: 2