libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [libcloud] gvengel opened a new pull request #1326: Fix hash validation with stream uploads
Date Fri, 26 Jul 2019 21:17:50 GMT
gvengel opened a new pull request #1326: Fix hash validation with stream uploads
   ## Fix hash validation with stream uploads
   ### Description
   Bug fix for cloudfiles upload_object_via_stream() erroneously throwing a hash mismatch
when using a file handle as the iterator. Example:
   from import get_driver
   from import ObjectDoesNotExistError
   driver = get_driver('cloudfiles')
   driver = driver('user', 'key')
   container = driver.get_container(container_name='test')
   with open('/tmp/test.file', 'w') as fh:
   with open('/tmp/test.file') as fh:
       driver.upload_object_via_stream(iterator=fh, container=container, object_name='test.file')
   This would result in the exception:
   ``` <ObjectHashMismatchError in <
object at 0x103f43d68>, value=MD5 hash checksum does not match (expected=d41d8cd98f00b204e9800998ecf8427e,
actual=098f6bcd4621d373cade4e832627b4f6), object = test.file>
   d41d8cd98f00b204e9800998ecf8427e is the hash for an empty file. The problem is the upload
happens before the hash is calculated and the file handle is read to the EOF. The fix is to
seek the file handle to the beginning before feeding it into the hash function.
   ### Status
   done, ready for review
   ### Checklist (tick everything that applies)
   - [x] [Code linting](
(required, can be done after the PR checks)
   - [ ] Documentation
   - [ ] [Tests](
   - [ ] [ICLA](
(required for bigger changes)

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:

With regards,
Apache Git Services

View raw message