January 2020
Intermediate to advanced
530 pages
11h 11m
English
The iwrite() method accepts the location of a file in the local server storage as an input parameter. It then adds this file to the IPFS network and returns the hash of the document to the function invoker.
The method receives the path of the file in the filepath input parameter, as shown in the following code snippet:
async function iwrite (filepath) {
Next, it adds the file to IPFS by calling the ipfs client object. The client object submits the file to the IPFS client port 5001, as follows:
try{const results = await ipfs.addFromFs(filepath, { });
The IPFS client returns the hash of the file content. The iwrite() method returns this file hash to the invoker, like this:
return results; ...
Read now
Unlock full access