Error while uploading file to S3 bucket using Python boto3 library

0 votes

I am getting this error when I am trying to upload a file from my local computer to S3 bucket.

Here is the code I am using:

import boto3
s3 = boto3.resource('s3')
s3.create_bucket(Bucket= 'niteshbucket')
s3.Object('niteshbucket', 'helloworld.txt').upload_file(Filename='C:\Users\Nitesh\Desktop\helloworld.txt')

Nov 30, 2018 in AWS by Nitesh
• 3,080 points

edited Nov 30, 2018 by Priyaj 4,759 views

1 answer to this question.

0 votes

The error is basically saying that you have a escape character used in string. So as in the path mentioned for your file that you wish to upload in s3 bucket. Instead of using / you are supposed to use // so that / is not treated as a escape character.

import boto3
s3 = boto3.resource('s3')
s3.create_bucket(Bucket= 'niteshbucket')
s3.Object('niteshbucket', 'helloworld.txt').upload_file(Filename='C:\\Users\\Nitesh\\Desktop\\helloworld.txt')
answered Nov 30, 2018 by Aniket

Related Questions In AWS

0 votes
1 answer

AWS S3 uploading hidden files by default

versioning is enabled in your bucket. docs.aws.amazon.com/AmazonS3/latest/user-guide/….... the ...READ MORE

answered Oct 4, 2018 in AWS by Priyaj
• 58,090 points
5,438 views
–1 vote
1 answer

How to decrypt the encrypted S3 file using aws-encryption-cli --decrypt

Use command : aws s3 presign s3://mybucket/abc_count.png you get ...READ MORE

answered Oct 22, 2018 in AWS by Priyaj
• 58,090 points
4,858 views
0 votes
1 answer

Import my AWS credentials using python script

Using AWS Cli  Configure your IAM user then ...READ MORE

answered Nov 16, 2018 in AWS by Jino
• 5,810 points
2,585 views
0 votes
2 answers
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP