-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Can't put contents to s3 bucket outside of US standard region with file object #82
Comments
I'm assuming that the bucket you were trying to write to was a newly created bucket? In that case, you can receive a temporary redirect (307) when you try to access the bucket because the DNS records that have to be created to resolve the bucket using virtual-hosted addressing have not yet propagated throughout the network. This 307 redirect should, however, contain a Location header. Are you sure there was no location header present? |
Did more digging into this. You do get a location header with the region specific endpoint (bucket.s3region.amazonaws.com), but the problem is that the fileobj has been exhausted so Does requests provide anything to rewind a stream? Is this something we could do before requests retries the request? |
I spent more time researching this and have a few observations:
The reason I'd like to get this implemented is for better memory utilization in this branch of the CLI: https://github.com/jamesls/aws-cli/compare/memory-utilization This branch is ready to go, except that by switching from bytearrays to file objects, we run into this issue here. |
When you use a file like object as the body param to s3.PutObject for a bucket outside of US standard, you'll get a 307 followed by a 400 bad request and eventually a socket timeout. To repro:
op.call(endpoint, body=open('/some/file', 'rb'), ...)
You'll see a 307 then a 400. I think this is because requests is configured to follow redirects, but there's no location header and hence the bad request.
I think the fact that this is a file like object exposes the bug because we send two packets, one for the request+headers then one for the body. When the body is a string (like what we use in the integration tests), then httplib will do a
msg += message_body
and send it as a single chunk which succeeds.This also might be related to the virtual host handler we have. I noticed this in the log messages:
Would be good to get an integration test written for this also.
The text was updated successfully, but these errors were encountered: