Git Product home page Git Product logo

js-thumbor-dash's Introduction

js-thumbor-dash

Universal JavaScript library for integrating Dash's distributed image thumbnail service in client applications

Installation

npm install git+https://github.com/mayoreee/js-thumbor-dash.git

Usage

Upload Image

import { ThumbnailClient } from 'js-thumbor-dash';

const options = {
  network: 'testnet',
  masternode: 'localhost:8888', // Server address [ip:port]
  contractId: 'DbBHu3Ct1zD1AYAiw58V7QXT22B3k7qRLDLfaXqiRQp5',
  documentType: 'thumbnailField',
  mnemonic: '< Insert mnemonic >', // Owner's wallet mnemonic
  ownerId: '< Insert owner identity >', // Owner's identity
  image: '< Insert image Buffer data >', // Image is a Buffer type
  resizeValues: [minWidth, minHeight, maxWidth, maxHeight], // Image resize constraints
};

const client = new ThumbnailClient(options);

try {
  const res = await client.upload();
  console.log(res.json());
} catch (err) {
  console.error(err);
}

Retrieve Image

import { ThumbnailClient } from 'js-thumbor-dash';

const options = {
  network: 'testnet',
  masternode: 'localhost:8888', // Server address [ip:port]
  contractId: 'DbBHu3Ct1zD1AYAiw58V7QXT22B3k7qRLDLfaXqiRQp5',
  documentType: 'thumbnailField',
  ownerId: '< Insert owner identity >', // Owner's identity
  updatedAt: 10292902020, // Integer timestamp
  requesterId: '< Insert requester identity >', // Requester's identity
  requesterPubKey: '< Insert requester public key>' // Requester public key
  width: 1200 // Image resize width
  height: 800 // Image resize height
};

const client = new ThumbnailClient(options);

try {
  const res = await client.retrieve();
  console.log(res.json());
} catch (err) {
  console.error(err);
}

Update Image

import { ThumbnailClient } from 'js-thumbor-dash';

const options = {
  network: 'testnet',
  masternode: 'localhost:8888', // Server address [ip:port]
  contractId: 'DbBHu3Ct1zD1AYAiw58V7QXT22B3k7qRLDLfaXqiRQp5',
  mnemonic: '< Insert mnemonic >', // Owner's wallet mnemonic
  ownerId: '< Insert owner identity >', // Owner's identity
  updatedAt: 10292902020, // Integer timestamp
  image: '< Insert new image Buffer data >', // Image is a Buffer type
};

const client = new ThumbnailClient(options);

try {
  const res = await client.update();
  console.log(res.json());
} catch (err) {
  console.error(err);
}

js-thumbor-dash's People

Contributors

mayor444 avatar mayoreee avatar wizlee avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.