What is the problem this feature will solve?
As of now, the Blob class only supports data in memory while the spec allows it to be both memory and file based. This has the possibility to use up a lot of memory when writing a lot of data. An example of this would be in the motivator for this change: undici's multipart/form-data support where it stores the entire response file in memory (https://github.com/nodejs/undici/pull/1606/files#diff-bd6db9a8bceb4e9fce3f93ba5284c81f46a44a1187909e8609006e1efeab2570R427).
What is the feature you are proposing to solve the problem?
Adding support to Blob to work either off of memory or a file.
- C++ side: keep the current
Blob class the same and make a separate class called FileBlob.
- Implements the exact same api, only difference is it would use a file (through
std::fstream or something) rather than a vector.
- Javascript side: No breaking changes to the existing Javascript api. It would use the exact same
Blob class that already exists, just with its native handle pointing to a FileBlob instance rather than Blob.
- Javascript side: Create method
fs.getFileBlob('some-file-path.txt') to get a Blob instance that is file-based
- If no file path is provided, a file is created in the temp directory under some random name
I'm currently working on implementing this and opened this issue to get some feedback on it.
cc @mcollina
What alternatives have you considered?
No response
What is the problem this feature will solve?
As of now, the
Blobclass only supports data in memory while the spec allows it to be both memory and file based. This has the possibility to use up a lot of memory when writing a lot of data. An example of this would be in the motivator for this change: undici's multipart/form-data support where it stores the entire response file in memory (https://github.com/nodejs/undici/pull/1606/files#diff-bd6db9a8bceb4e9fce3f93ba5284c81f46a44a1187909e8609006e1efeab2570R427).What is the feature you are proposing to solve the problem?
Adding support to
Blobto work either off of memory or a file.Blobclass the same and make a separate class calledFileBlob.std::fstreamor something) rather than a vector.Blobclass that already exists, just with its native handle pointing to aFileBlobinstance rather thanBlob.fs.getFileBlob('some-file-path.txt')to get aBlobinstance that is file-basedI'm currently working on implementing this and opened this issue to get some feedback on it.
cc @mcollina
What alternatives have you considered?
No response