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 libcloud.storage.types import Provider
|
||||
from libcloud.storage.providers import get_driver
|
||||
|
||||
@ -26,11 +28,11 @@ class Uploader:
|
||||
)
|
||||
|
||||
object_name = uuid4().hex
|
||||
self.container.driver._put_object(
|
||||
stream=iter(fyle.stream),
|
||||
container=self.container,
|
||||
with NamedTemporaryFile() as tempfile:
|
||||
tempfile.write(fyle.stream.read())
|
||||
self.container.upload_object(
|
||||
file_path=tempfile.name,
|
||||
object_name=object_name,
|
||||
verify_hash=False,
|
||||
extra={"acl": "private"},
|
||||
)
|
||||
return (fyle.filename, object_name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user