Upload with a temp file instead of streaming
Using a stream is a no-go due to a bug in libcloud: https://issues.apache.org/jira/browse/LIBCLOUD-935?focusedCommentId=16152982&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16152982 Instead, write the uploaded file to a named tempfile and pass that to the uploader.
This commit is contained in:
parent
4e16346ed4
commit
501caf767b
@ -1,4 +1,6 @@
|
|||||||
|
from tempfile import NamedTemporaryFile
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from libcloud.storage.types import Provider
|
from libcloud.storage.types import Provider
|
||||||
from libcloud.storage.providers import get_driver
|
from libcloud.storage.providers import get_driver
|
||||||
|
|
||||||
@ -26,13 +28,13 @@ class Uploader:
|
|||||||
)
|
)
|
||||||
|
|
||||||
object_name = uuid4().hex
|
object_name = uuid4().hex
|
||||||
self.container.driver._put_object(
|
with NamedTemporaryFile() as tempfile:
|
||||||
stream=iter(fyle.stream),
|
tempfile.write(fyle.stream.read())
|
||||||
container=self.container,
|
self.container.upload_object(
|
||||||
object_name=object_name,
|
file_path=tempfile.name,
|
||||||
verify_hash=False,
|
object_name=object_name,
|
||||||
extra={"acl": "private"},
|
extra={"acl": "private"},
|
||||||
)
|
)
|
||||||
return (fyle.filename, object_name)
|
return (fyle.filename, object_name)
|
||||||
|
|
||||||
def download(self, path):
|
def download(self, path):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user