fission-codes / ipfs-haskell

IPFS wrapper for Haskell
https://hackage.haskell.org/package/ipfs
Apache License 2.0
43 stars 5 forks source link

Unable to send to Remote #35

Open bhoudebert opened 2 years ago

bhoudebert commented 2 years ago

Hi,

First of all, not really a bug but more of a lacking of how to achieve it.

We are trying to add something to IPFS with the library, using the remote part.

add is expecting a ByteString but there is no documentation of how to format that ByteString. Therefore it does not work and ask for the famous path argument (which is not even this name but error come from ipfs node anyway).

So how do we call the function add to provide the file name and also the encoding maybe?

res <- runRemote (add "blabla")

Anyway, I read the IPDS doc, still not clear to me.

curl --location --request POST 'http://localhost:5001/api/v0/add' \
--form 'myfile.txt="kkk"'
# returns
{
    "Name": "QmSj2KoTnMesarHGBRiWkh8TxqrwjgpayAmxLWFK56TEfc",
    "Hash": "QmSj2KoTnMesarHGBRiWkh8TxqrwjgpayAmxLWFK56TEfc",
    "Size": "11"
}

This is not totally working, uploaded to ipfs node but the name is trash and therefore cannot handle any directly I assume, still the content is "okay" with "kkk" as value.

I assume I am missing something for the Haskell part, thanks for any tips there (may offer you later a documentation PR + some free examples if you wish)

github-actions[bot] commented 2 years ago

Thank you for submitting an issue! It means a lot that you took the time -- it helps us be better 🙏