Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unsuccessful upload does not raise exception #18

Open
danmilon opened this issue Apr 30, 2014 · 0 comments
Open

unsuccessful upload does not raise exception #18

danmilon opened this issue Apr 30, 2014 · 0 comments

Comments

@danmilon
Copy link

import tinys3

conn = tinys3.Connection(S3_ACCESS_KEY,S3_SECRET_KEY,tls=True)

f = open('some_file.zip','rb')
conn.upload('some_file.zip',f,'my_bucket')

The bucket resides in the eu-west-1 region. The code above completes successfully, but here's the HTTP communication:

PUT /my-backet/some_file.zip HTTP/1.1

Host: s3.amazonaws.com
Date: Wed, 30 Apr 2014 10:36:02 GMT
Accept: */*
Content-Length: 4151
Authorization: [...]
x-amz-acl: public-read
User-Agent: python-requests/2.2.1 CPython/3.4.0 Linux/3.14.1-1-ARCH
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document
Accept-Encoding: gzip, deflate, compress
HTTP/1.1 301 Moved Permanently

x-amz-request-id: [...]
x-amz-id-2: [...]
Content-Type: application/xml
Transfer-Encoding: chunked
Date: Wed, 30 Apr 2014 10:35:50 GMT
Connection: close
Server: AmazonS3

1d3
<?xml version="1.0" encoding="UTF-8"?>
<Error><Code>PermanentRedirect</Code><Message>The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.</Message><RequestId>[...]</RequestId><Bucket>my-bucket</Bucket><HostId>[...]</HostId><Endpoint>my-bucket.s3.amazonaws.com</Endpoint></Error>
0

I noticed raise_for_status() is called, but I suppose 301 is not considered an error, thus no exception is raised.

I know I should provide the endpoint to tinys3 but I believe the code should check explicitly for status >= 300 and raise accordingly in order to avoid silently failing requests.

@shlomiatar, what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant