0.0.1 • Published 1 year ago

dstor-sdk v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Dstor SDK that allows you to work with a global storage dStor

Installation

Using npm:

$ npm install dstor-sdk

Once the package is installed, you can import the library using import or require approach.

Import for react:

import { Dstor } from 'dstor-sdk-test/react';

Import for node.js:

const { Dstor } = require('dstor-sdk-test/node');

Getting Started

First you need to specify ApiBase in the constructor:

const { Dstor } = require('dstor-sdk-test/node');

const store = new Dstor("xxx");

Dstor.authentication(mail: string, password: string);

const { Dstor } = require('dstor-sdk-test/node');

// xxx = testntet, potroast, production
const store = new Dstor('xxx');

const result = await store.authentication('mail', 'password'); // return: "Authentication successful!"

Dstor.apiBaseUrl

const { Dstor } = require('dstor-sdk-test/node');

const store = new Dstor('xxx');

const result = store.apiBaseUrl // api.xxx.Dstor.cloud

Dstor.getFileInfo(hash: string)

hash: hash that belongs to the file on dStor
const { Dstor } = require('dstor-sdk-test/node');

const store = new Dstor('xxx');

const result = store.getFileInfo('xxxxxxxxxxx'); // [{file_name: ... , file_hash: ... , file_size: ... , ......}]

Dstor.downloadFile(path: string, hash: string)

path: the full path where to save the file on the device

hash: hash that belongs to the file on dStore
const { Dstor } = require('dstor-sdk-test/node');

const store = new Dstor('xxx');

const result = store.downloadFile('xxxxx', 'xxxxxxxxxxx'); // return: Download finished: file_name

Dstor.uploadFile(data: string | any[])

data: for node.js the full path of the file (or array of path). For React e.target.files (or array of files)
const { Dstor } = require('dstor-sdk-test/node');

const store = new Dstor('xxx');

const result = store.uploadFile(['path', 'path', ...]); // return: Upload successfully!
0.0.1

1 year ago

1.0.0

1 year ago