You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to copy a file from the MemoryFileSystem to the LocalFileSystem (basically, write it to disk). When I try to run the following, I get the below error (localFileSystemPath is '/Users/mikem/example.mp4')
FileSystemException (FileSystemException: No such file or directory, path = 'Users' (OS Error: No such file or directory, errno = 2))
I assume this happens because file.copy tries to copy into a new file on its own filesystem (MemoryFileSystem) but the local file system's /Users directory isn't there. What is the recommended way to copy a file from one FileSystem to another? And can this be done without making an extra copy of the data in memory?
The following does work, but requires the entire file to be read into memory before writing can even begin. Maybe this isn't an issue because it's already in memory (it's on a MemoryFileSystem), and the readAsBytesSync call shortcuts and returns a reference to the existing list of bytes? Just trying to figure out the best way to write a potentially very large file from memory to disk, and this doesn't seem like it. Can't this be done in chunks with Streams to avoid having to read the whole file at once?
memoryFilesystemFile.readAsBytesSync() shouldn't need to do any new allocations - the "file" is already basically just a Uint8List in memory. How would streams help here?
I guess I figured there would be a way to read a file as a stream, where only small chunks were ever loaded into memory at a time as they are, in my case, written directly to a file on another FileSystem.
But in a MemoryFileSystem, the file is already just an in memory list of bytes, right?
In a regular file system implementation that would make sense, but right now Dart itself doesn't have API for that (you can only read files in their entirety in Dart). There's probably a bug in dart-lang/sdk somewhere for that....
I'd like to copy a file from the MemoryFileSystem to the LocalFileSystem (basically, write it to disk). When I try to run the following, I get the below error (localFileSystemPath is '/Users/mikem/example.mp4')
I assume this happens because file.copy tries to copy into a new file on its own filesystem (MemoryFileSystem) but the local file system's /Users directory isn't there. What is the recommended way to copy a file from one FileSystem to another? And can this be done without making an extra copy of the data in memory?
The following does work, but requires the entire file to be read into memory before writing can even begin. Maybe this isn't an issue because it's already in memory (it's on a MemoryFileSystem), and the readAsBytesSync call shortcuts and returns a reference to the existing list of bytes? Just trying to figure out the best way to write a potentially very large file from memory to disk, and this doesn't seem like it. Can't this be done in chunks with Streams to avoid having to read the whole file at once?
The text was updated successfully, but these errors were encountered: