1.0.4 • Published 5 months ago

@bws-sdk/ipfs v1.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

BWS IPFS SDK

Official Blockchain Web Services IPFS solution NodeJS SDK.

Create Release

Overview

Blockchain Web Services (BWS) is a comprehensive platform offering a suite of blockchain-based solutions, designed to simplify and enhance the integration of blockchain technology into various business and individual needs.

This SDK provides the easiest way to save data into the InterPlanetary File System (IPFS). Use it to save your NFT metadata and images.

Installation

npm install --save @bws-sdk/ipfs

How to use it

Once installed, just import the SDK, create an instance using your API Key and start using the available functions. To get your API Key go to www.bws.ninja and sign up - it's free.

import { BWSIPFS } from @bws-sdk/ipfs;
const ipfs = new BWSIPFS('<your API key>')

Operations

Use the following available operations:

All the operations will return the following IPFS related information (pointing to your newly created IPFS file):

{
    "cid": "QmU7avmnTb4iVbNGCHMJmdEbsx9nRtUx7dWGpKeE7zjo8T",
    "uris": {
        "ipfs": "ipfs://QmU7avmnTb4iVbNGCHMJmdEbsx9nRtUx7dWGpKeE7zjo8T",
        "url": "https://ipfs.bws.ninja/ipfs/QmU7avmnTb4iVbNGCHMJmdEbsx9nRtUx7dWGpKeE7zjo8T"
    }
}

uploadJSONAsync

Upload a JSON to IPFS. You can pass the JSON object or the string representation.

import { BWSIPFS } from @bws-sdk/ipfs;
const ipfs = new BWSIPFS('<your API key>')

await ipfs.uploadJSONAsync({ timestamp: Date.now() }).then(data => {
    console.log(data);
}).catch(err => {
    console.log(err);
});

uploadFileAsync

Upload a file to IPFS by indicating the file path.

import { BWSIPFS } from @bws-sdk/ipfs;
const ipfs = new BWSIPFS('<your API key>')

await ipfs.uploadFileAsync('./files/image.png').then(data => {
    console.log(data);
}).catch(err => {
    console.log(err);
});

uploadStreamAsync

Upload content to IPFS by passing a stream.

import fs from 'fs';

import { BWSIPFS } from @bws-sdk/ipfs;
const ipfs = new BWSIPFS('<your API key>')

await ipfs.uploadFileAsync(fs.createReadStream('./files/image.png').then(data => {
    console.log(data);
}).catch(err => {
    console.log(err);
});

Have a question? Found an issue?

Please feel free to file an issue or send us an email: hello@bws.ninja.

Need an extended feature or some help?

Please do not hesitate to ask for help or an extended feature for your project use case, we love improving!

1.0.4

5 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago