I’d like to employ IPFS in a .NET POC app and if this POC becomes successful, that will probably be a permanent implementation. The goal is to store and pin an object (not a file) in an IPFS node or nodes (cluster). This object can be as simple as a string, a JSON representation of an object, or even a binary representation of an object.
I was browsing through the HTTP client API reference document and failed to find such a capability to add an object to IPFS. I realized that the only way is to upload a file which is far from what I’d like to achieve. Technically I do not want to create a file per object and have it uploaded because it’s impractical. Appreciate your help!
If you’re working with the HTTP API, in order to
add, you don’t need to refer to a file. Instead, you totally can just pass the data itself. Curl example:
curl -X POST "http://localhost:5001/api/v0/add" --form-string "content=Hello, this is my string\!"
Docs (contains lots of useful information about what headers are expected and why): /api/v0/add
Thanks. that curl statement worked for me but I could not find the necessary headers list in the documentation. Am I looking at the wrong place?
They are there under the “Request Body” section. I used them to build this code (Go): ipfs-sync/main.go at master · TheDiscordian/ipfs-sync · GitHub
Unfortunately I don’t have a .NET example… but those docs are what I used to write that code.