1.1.0 • Published 1 year ago

@web3sdkio/storage v1.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

Installation

Install the latest version of the SDK with either npm or yarn:

npm install @web3sdkio/storage
yarn add @web3sdkio/storage

Quick Start

Once you have the Web3sdkio Storage SDK installed, you can use it to easily upload and download files and other data using decentralized storage systems.

Here's a simple example using the SDK to upload and download a file from IPFS:

import { Web3sdkioStorage } from "@web3sdkio/storage";

// First, instantiate the SDK
const storage = new Web3sdkioStorage();

// Now we can upload a file and get the upload URI
const file = readFileSync("path/to/file.jpg");
const uri = await storage.upload(file);

// Finally we can download the file data again
const res = await storage.download(uri);
const data = await res.text();

Alternatively, we can use the SDK to upload and download metadata and JSON objects, and we can also upload multiple items at once:

// We define metadata for 2 different NFTs
const metadata = [
  {
    name: "NFT #1",
    description: "This is my first NFT",
    image: readFileSync("path/to/file.jpg"),
    properties: {
      coolness: 100,
    },
  },
  {
    name: "NFT #2",
    description: "This is my second NFT",
    image: readFileSync("path/to/file.jpg"),
    properties: {
      coolness: 200,
    },
  },
];

// And now we can upload it all at once to a single directory
const uris = await storage.uploadBatch(metadata);

// And easily retrieve the metadata
const metadata = await storage.downloadJSON(uris);

Learn More

You can learn more about web3sdkio and the Storage SDK with the following resources:

1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago