-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Support node's ReadStream in ipfs.add instead of AsyncIterable<Uint8Array> / Iterable<Uint8Array> #3188
Comments
While we're at it I would also like to propose to remove It introduces this ambiguity when it comes to choosing right strategy. Which is something I have faced both in #3022 and #3151 It becomes unclear whether chunks are already in memory (where better strategy would be to collect them and pass them together down the pipe) or not e.g. they are generated on consumption (in which case it would be better to avoid buffering). It is also not a purely an optimization thing, it adds complexity to the implementation as well. Which is why I would like to propose dropping
|
The whole idea here is that node streams are async iterators, and we use async iterators internally extensively, so let's just support async iterators and have everything else convert to that. Non-async iterators still work with We support Blobs so people can drag and drop files into a UI, but they'll get turned into an async iterator internally when running a node in-browser. If we're just running the HTTP client in the browser, then we can keep Blobs as Blobs and pass them to FormData to send to the remote node. When it arrives at the remote node we're back to async iterators.
If the user has chunks, they should be able to just pass them in without making any choices. No wrapping with a Blob or a file object. |
I'm curious about this one too. The full stack trace in my case:
In terms of version, i am using the latest at the moment of writing. For |
I have the same issue |
js-ipfs is being deprecated in favor of Helia. You can learn more about this deprecation and read the migration guide. Please feel to reopen with any comments by 2023-06-02. We will do a final pass on reopened issues afterwards (see #4336). Please attempt to use Helia for the same and open a bug there if you're still running into issues! |
This is a followup to #3167. I have proposed to simplify
ipfs.add
even further by removingIterable<Uint8Array>
andAsyncIterable<Uint8Array>
from the list of possible input types.As per #3167 (comment) (quoted bolew for convenience)
We could get rid of
Iterable<Uint8Array>|AsyncIterable<Uint8Array>
and still support above use case, by adding nodeReadStream
(which is whatfs.createReadStream
returns) to the list of accepted options.That would significantly reduce complexity of the
normaliseInput
and wire protocol encoder used in the #3022, but more importantly it remove mental overhead of the API and all the false positives that can occur when probing inputs.The text was updated successfully, but these errors were encountered: