Closed Rkrushanovskij closed 4 years ago
Hello? :(
Are you using content._readableState.length
? Firstly, I would suggest not depending on this value, by convention underscore prefixed members are considered private and are not usually part of the public API.
Secondly, streams by their nature are not guaranteed to know their length before they are consumed. There is nothing in the public API for streams that allows you to know this.
You could consume the stream and then you'd know the length or you can use ipfs.ls
to get size information for a given file.
Hope that helps.
After migration to the latest
ipfs-http-client
version I faced troubles with getReadableStream. Versions:32.0.1 -> 40.1.0
I am uploading file to IPFS from FS using:
ipfs.addFromFs(path, options)
and getting such result:AFAIU it means that file uploaded successfully and this hash have some content (non-zero size).
I am trying to get readable stream from IPFS for this file but returned stream is 0 length:
ipfs.getReadableStream(hash)
It is strange that same hash that during uploading had size 72 now displayed as zero-length.