Don't verify hash of uploaded files

I believe this is a bug in `libcloud`. We're passing an iterator (as
required by libcloud --
https://github.com/apache/libcloud/blob/trunk/libcloud/storage/base.py#L592)
for the stream, but when verifying the hash of the uploaded file,
  `libcloud` goes through the stream twice: https://github.com/apache/libcloud/blob/trunk/libcloud/storage/base.py#L614-L621

After the sending the file stream as an upload, when generating the
hash, the iterator has already been iterated through so the second
go-through returns an empty iterator. Thus, the hash will never match
unless an empty file is uploaded.

This change reaches into the container's driver so that we can pass the
`verify_hash` kwarg, which cannot be specified on the container's
methods.
This commit is contained in:
Patrick Smith 2018-08-28 20:35:31 -04:00
parent 1594103847
commit 4e16346ed4

View File

@ -26,9 +26,11 @@ class Uploader:
)
object_name = uuid4().hex
self.container.upload_object_via_stream(
iterator=fyle.stream.__iter__(),
self.container.driver._put_object(
stream=iter(fyle.stream),
container=self.container,
object_name=object_name,
verify_hash=False,
extra={"acl": "private"},
)
return (fyle.filename, object_name)