Upload data from a webpage to an IPFS

Viewed 193

How can we upload data from a webpage to an IPFS server? In IPFS, I have already uploaded a .txt/JSON empty file. The file can either be a .txt or a JSON file.

1 Answers

If i understand your question correctly,you are trying to upload something from your webpage to IPFS cluster(at least this is the basic context i understand). So with this intent i would say this is possible. What you need to do is a. Upload the file in a local IPFS node using the IPFS api(Read the official documentation) and getting the content identifier(cid) from your webpage.

Problem:

  1. What happens when the local node is not available?(You shutdown your computer simply!!)
  2. The file yo upload will be garbage collected after it is not used for some time as a result you lose the data completely.

Solution:

Use a Pinning service.Pinning is the mechanism that allows you to tell IPFS to always keep a given object somewhere where it is always accessible and save it from the internal Garbage collection that the system performs.

The default pinning location is your local computer node and you can do that using the IPFS specified API. You can also use other pinning service available like Pinnata where you can host the content in their node itself(You scale the number of nodes and you pay!)

In this way you can guarantee that the content is always served and online.

Hope this helps you to get started with.

Related