restipfs¶
Source | restipfs |
---|
The restipfs is a local copy of browser ipfs including some small adjustments, to handle a lightweight rest based ipfs connection. It is used to initial files (before bcc and browserified ipfs-js loaded) and small DBCP descriptions.
api_url¶
ipfs.api_url(path);
build the api connection url
Parameters¶
path
-string
: path to build the api url for
Returns¶
`string
: full api enchanced path
add¶
ipfs.add(input, callback);
Adds a file to the ipfs
Parameters¶
input
-string
: string input of the filecallback
-Function
: callback called when finished adding
catText¶
ipfs.catText(ipfsHash, callback);
Returns a string that is loaded from a ipfs hash
Parameters¶
ipfsHash
-string
: ipfs hash to loadcallback
-Function
: callback called when finished loading
Returns¶
string
: result of the ipfs hash
addJson¶
ipfs.addJson(jsonObject, callback);
Serializes a json object and saves it using ipfs.add
Parameters¶
jsonObject
-object
: json object to savecallback
-Function
: callback that is called when finished request
catJson¶
ipfs.catJson(ipfsHash, callback);
Load data from an ipfs hash and tries an JSON.parse on the result
Parameters¶
ipfsHash
-string
: ipfs hash to loadcallback
-Function
: callback called when finished loading
Returns¶
object
: resolved when done
Example¶
ipfs.catJson('Qmb...', (result) => console.log(result)) // ==> { text: "hello world, wohooo" }