Comments (3)
how to resolve this ?
from fake-s3.
def monkey_patch_boto():
from boto.exception import PleaseRetryException
def should_retry(self, response, chunked_transfer=False):
provider = self.bucket.connection.provider
if not chunked_transfer:
if response.status in [500, 503]:
# 500 & 503 can be plain retries.
return True
if response.getheader('location'):
# If there's a redirect, plain retry.
return True
if 200 <= response.status <= 299:
self.etag = response.getheader('etag')
md5 = self.md5
if isinstance(md5, bytes):
md5 = md5.decode('utf-8')
# If you use customer-provided encryption keys, the ETag value that
# Amazon S3 returns in the response will not be the MD5 of the
# object.
server_side_encryption_customer_algorithm = response.getheader(
'x-amz-server-side-encryption-customer-algorithm', None)
if server_side_encryption_customer_algorithm is None:
if self.etag != '"%s"' % md5 and self.etag != md5:
raise provider.storage_data_error(
'ETag from S3 did not match computed MD5. '
'%s vs. %s' % (self.etag, self.md5))
return True
if response.status == 400:
# The 400 must be trapped so the retry handler can check to
# see if it was a timeout.
# If ``RequestTimeout`` is present, we'll retry. Otherwise, bomb
# out.
body = response.read()
err = provider.storage_response_error(
response.status,
response.reason,
body
)
if err.error_code in ['RequestTimeout']:
raise PleaseRetryException(
"Saw %s, retrying" % err.error_code,
response=response
)
return False
Key.should_retry = should_retry
from fake-s3.
example:
monkey_patch_boto()
connection = S3Connection(S3_ACCESSED_ID,
S3_SECRECT_ACCESS_KEY,
host=S3_HOST,is_secure=False)
print connection.connection
b = connection.get_bucket("result")
print b
k = Key(b)
tkey = "forbar".encode("utf-8")
k.key = tkey
print k.md5
print k.etag
md5str = hashlib.md5('hello'.strip()).hexdigest()
print md5str
k.set_contents_from_string(tkey)
print k.get_contents_as_string()
have a try?
from fake-s3.
Related Issues (20)
- [Feature] Add support of payer option, to allow usage with ansible s3_bucket library
- fakes3 error
- [Bug] Error message "undefined method `gsub' for nil:NilClass" when attempting to store something.
- [Bug] Multipart Upload Fails for Large Files
- Incorrect behavior when using Prefix HOT 1
- [Other] LoadError: load error: jopenssl/load -- java.lang.IncompatibleClassChangeError: Implementing class
- [Bug] X-Amz-Content-Sha256 is not allowed for upload
- [Feature] Multipart upload more descriptive error message for uploading one part HOT 2
- License timebomb should be a major version HOT 3
- [Question] Next release? HOT 1
- [Feature] Support GET Bucket requestPayment
- [QUESTION] Where I can find the CI service? HOT 1
- [Bug] Deleting "fake" directories
- [Bug] Licensing does not work for certain valid email addresses HOT 5
- [Bug] Cannot upload files with size > 2GB
- [Question]: Are files actually created when uploading or is file creation simulated?
- [Bug] Prevent directory traversal
- "rake test_sever" not working in windows. is there any way to resolve this ? HOT 1
- Ruby 3.1 compatibility HOT 1
- [Feature] Support for AWS v3 SDK
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fake-s3.