Skip to content

fs.cp_file: out of memory error (don't store file in RAM) #138

Open
@casperdcl

Description

@casperdcl

def cp_file(self, lpath, rpath, **kwargs):
"""In-memory streamed copy"""
with self.open(lpath) as stream:
# IterStream objects doesn't support full-length
# seek() calls, so we have to wrap the data with
# an external buffer.
buffer = io.BytesIO(stream.read())
self.upload_fobj(buffer, rpath)

ref. #119 (review) suggestion:

-    """In-memory streamed copy""" 
-    with self.open(lpath) as stream: 
-        # IterStream objects doesn't support full-length 
-        # seek() calls, so we have to wrap the data with 
-        # an external buffer. 
-        buffer = io.BytesIO(stream.read()) 
-        self.upload_fobj(buffer, rpath) 
+        with self.open(lpath) as stream:
+            self.upload_fobj(stream, rpath)

and fix self.open to return a proper stream.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions