1

I'm working on a react app using IPFS to store files, currently using superagent for making the requests. I can add files no problem from the web app for example:

URL: http://127.0.0.1:5001/api/v0/add

------WebKitFormBoundary9gG5B69BhTfpMoyB
Content-Disposition: form-data; name="blahblahfile.mp3"; filename="blahblahfile.mp3"
Content-Type: audio/mp3


------WebKitFormBoundary9gG5B69BhTfpMoyB--

But now i'm trying to implement an unpinning feature, which isn't working. I make a request with the following:

pin : (action, hash) => {
    const url = ipfs.getUrl(`pin/${action}`)
    const req = request.post(url)

    if (hash) {
      req.query({
        args : hash,
        recursive : true
      })
    }

    return req
  }

which sends a url like: http://127.0.0.1:5001/api/v0/pin/rm?args=QmWzCL86fMNoGjsdYW88VV9AGCV4TFX1ddKzYHzGHbGmGj&recursive=true

and then garbage collect: http://127.0.0.1:5001/api/v0/repo/gc

all the requests go through successfully but the item isn't removed. One thing i think is odd is in the response for the pin/rm request there are no pins listed in the Pins array. My understanding is that it will return the hash you just unpinned.

I feel like it's the pin/rm that is failing somewhere but i'm not exactly sure where. Note that i can perform these commands in the terminal and everything get's unpinned and garbage collected properly.

Has anybody had a similar experience? Got any tips? Let me know if you need any more info, thanks!

Shan Robertson
  • 2,742
  • 3
  • 25
  • 43
  • Are you using curl in console for testing? Did you make sure that the string of pin/ls and pin/rm match? – xDreamCoding Nov 12 '17 at 23:23
  • i'm using the go-ipfs command line tools. and yes they match. My app keeps the hash in a db. and i would, for example, run the remove command in the browser, it wouldn't work, copy/paste the hash into terminal and run the remove command and it would work. That's why i'm lead to believe it's something in the http request i'm making. – Shan Robertson Nov 13 '17 at 00:06
  • Hi there! Which go-ipfs version are you using? Are you making the requests yourself or using something like https://github.com/ipfs/js-ipfs-api ? – David Dias Nov 13 '17 at 08:49
  • I'd advise to use curl and see if the http endpoint works as expected. After that you can check if your http call from browser matches your curl call. – xDreamCoding Nov 13 '17 at 13:04
  • @DavidDias i'm using 0.4.11 for go-ipfs, and that works as expected, i can interact with my files as the docs describe. I'm not using the js package, just regular xhr calls (using superagent) to the http api. I've updated my question with the exact function i use. – Shan Robertson Nov 13 '17 at 18:44
  • Any reason on why to avoid using https://github.com/ipfs/js-ipfs-api/ ? – David Dias Feb 21 '18 at 10:24

0 Answers0