A PHP Error was encountered

Severity: Warning

Message: filemtime(): stat failed for D:\xampp_old\htdocs\ebookreading.net\application\writable1/ci_session1423ea9e5b9a0ffe73e877db69964f2dn5mv2el2h0h5b4daj7bvkl2e1vsnhgus

Filename: controllers/Base.php

Line Number: 44

Backtrace:

File: D:\xampp_old\htdocs\ebookreading.net\application\controllers\Base.php
Line: 44
Function: filemtime

File: D:\xampp_old\htdocs\ebookreading.net\application\controllers\View.php
Line: 10
Function: __construct

File: D:\xampp_old\htdocs\ebookreading.net\index.php
Line: 380
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: filemtime(): stat failed for D:\xampp_old\htdocs\ebookreading.net\application\writable1/ci_session1423ea9e5b9a0ffe73e877db69964f2dn9j4knobpqlo7ggognb0bm7skmq7tb00

Filename: controllers/Base.php

Line Number: 44

Backtrace:

File: D:\xampp_old\htdocs\ebookreading.net\application\controllers\Base.php
Line: 44
Function: filemtime

File: D:\xampp_old\htdocs\ebookreading.net\application\controllers\View.php
Line: 10
Function: __construct

File: D:\xampp_old\htdocs\ebookreading.net\index.php
Line: 380
Function: require_once

Writing a method to publish documents to the IPFS network

Writing a method to publish documents to the IPFS network

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;
}catch (error) {
console.error(`Failed to write: ${error}`);
}
}

A catch statement catches any errors while adding the file to the IPFS network. 

That brings us to the end of the iwrite() method. Next, let's look at the method that submits the transaction to the blockchain network.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.196.217