Lack of hash -> Buffer interface #164
Description
A noticeable gap in the APIs seems to be taking a hash and getting a buffer back.
The Scenario ... on the Archive.org gateway, we add a file to IPFS using the https..../api/v0/add" interface (working with Kyle) and get back a multihash-base58 that could EITHER
a) hash of the raw bytes (on a small file) or
b) the IPLD (for a larger file that got sharded).
The problem is turning that hash back to bytes in the JS, we've been using block.get() to retrieve it, but of course that files on case b.
Kyle has suggested using files.get() but this runs into the API limitation that files.cat returns a stream, and I'm guessing that a lot of people using this end up writing code to convert that Stream back into a buffer (so it can be passed to a Blob).
If I understand the code in files.js (and its possible that I don't), the code in cat() already has the whole file in a Buffer, which it converts into a Stream, which the caller then has to convert back into a buffer. Wouldn't it make a lot of sense to provide an API that allows returning it as a Buffer in the first place ?