This Node.js application allows you to easily pine files to IPFS using the Fleek SDK.
Before you begin, make sure you have the following installed:
- NodeJs 18+
- npm (Node Package Manager)
- fleek CLI (https://docs.fleek.xyz/docs/CLI)
Follow these steps to get started with the Fleek Node.js App:
-
Clone this repository:
git clone https://github.com/geniusyinka/fleek-ipfs.git
-
Navigate to the project directory:
cd fleek-ipfs
-
Install dependencies:
npm install
-
Obtain a Personal Access Token (PAT) from Fleek. Replace
<your-pat>
in the code with your actual PAT.
Once the application is running, follow these steps to upload a file to IPFS:
-
Ensure that the file you want to upload is in the project directory.
-
Update the filename in the code to match the file you want to upload:
const fileContent = fs.readFileSync('<filename>'); uploadFileToIPFS('<filename>', fileContent) .then(result => { console.log('File uploaded to IPFS:', result); }) .catch(error => { console.error('Error uploading file to IPFS:', error); });
-
Execute the application:
npx tsx index.ts
-
Upon successful execution, you will see a message indicating that the file has been uploaded to IPFS along with the resulting hash.