3

Is there an HTTP api equivalent of doing:

ipfs add -r resources/public

where resources/public is a directory with a static website (index.html in the root, css, js etc).

Doing:

 curl -F file=resources/public/index.html "http://$IPFS_HOST:5001/api/v0/add?recursive=true&wrap-with-directory=true"

Will only upload one file:

{"Name":"index.html","Hash":"QmZzbCaCPMEGJBLv7DJCDD2mvgkrvTg78MXYt7cPrQhge6","Size":"1255"}
{"Name":"","Hash":"QmdAGnATEQ1VoytC8L9h5nNepmiZCXv61ob49Dpz5nZVGf","Size":"1312"}
0

I have run into the same problem. I could be wrong, but this is presently not possible to do with Curl. I believe you can use the API inside a Javascript application to upload a path recursively, but with Curl you can only attach a single file, there is no recursive function built in for uploading directories.

If you find a solution do please let me know.

0

You can upload a website in IPFS in its entirety as long as it is static from my understanding.

Parallax websites with anchor links work wonders.

Just do this:

ADD TO IPFS: 1) ipfs add -r [ directory where web files are located ]

PIN IT SO IT DOESN'T DISAPPEAR FROM YOUR NODE IF YOUR DAEMON IS NOT ON: 2) ipfs pin add -r [IPFS hash from above] -Side Note: Make sure you copy the last hash to pin since that will be your root directory

TEST IT ON YOUR NODE: 3) http://localhost:port/ipfs/[IPFS hash]

It should work.

Here is an example of a demo parallax website I uploaded to IPFS. I'm using my own node as a gateway, not the default IPFS gateway:

http://mymobiservices.com:9001/ipfs/QmbaE6vj8xq2inkx5km7stKX3GSjeeKYt2QmB7opNXJhCB

Hope this answers your question. If you need help, let me know.

I'm still learning IPFS so bear with me as I may not know everything related to it.

Pavon

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.