From 4e16346ed438653c329cd2d0d767c6a93c82490d Mon Sep 17 00:00:00 2001 From: Patrick Smith Date: Tue, 28 Aug 2018 20:35:31 -0400 Subject: [PATCH] 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. --- atst/uploader.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/atst/uploader.py b/atst/uploader.py index 167c3d03..9f1ef62a 100644 --- a/atst/uploader.py +++ b/atst/uploader.py @@ -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)