How to make sure that the data is successfully uploaded to IPFS

tak
2 min readSep 5, 2018

--

Have you ever bothered whether a file have been uploaded to IPFS?
Thanks for contributors I sometime use IPFS as public file server to publish files to internet. Then, I manually check that a file was been shared among other nodes every time. This is annoying job. So I created a script to automate this job.

What IPFS command is suitable?

At first, I looked IPFS providing commands to find out suitable command to check upload.

At first, I tried to find out suitable ipfs command by reading API reference. Then, I thought this command may meet my aim.

ipfs dht findprovs <key>...  

The help of this command is “ — Find peers that can provide a specific value, given a key.”

This worked, but it took a lot of time until any key providing node is shown.

Accessing ipfs site is the most reliable way

I decided to mind to making sure upload completion by accessing “https://ipfs.io/ipfs/<key>”. I think this is the most accurate and reliable way. I created upload observing script based on this way.

Github: ipfs-local-uploader

Please execute as follow. IPFS daemon will start and add specified file or directory. Then, recursively access ipfs site until succeed.

node uploader.js <file path | diretory path>

Please note that your uploaded file will be disappear after 24h later. Because IPFS network garbage collect old resource. If you want to keep your data on internet forever, you need to upload again and again at least one a day or just keep a daemon working.

Thank you for reading. Let me apologize my poor English writing.

--

--

tak

Japanese software engineer. Like blockchain, sauna and manga. re795h@gmail.com