/KilatStorages3

NodeJs S3 client for Kilat Storage S3 and Amazon S3

Primary LanguageJavaScriptMIT LicenseMIT

KilatStorageS3 - NodeJs S3 Client for KilatStorage

npm download

This package is a S3 client for NodeJs 8.X or greater. KilatStorageS3 uses a bash command to run s3cmd which has been configured and connected to the kilatstorage service. You can use this package for Amazon S3 service too.

Requirements

  • KilatStorageS3 requires NodeJs 8.X or greater
  • s3cmd (already configured with kilatstorage service) - You can read this for more information.

Installation

npm i s3-kilatstorage

Usage

Make bucket

const kilatstorage = require('s3-kilatstorage');
kilatstorage.makeBucket('bucket-name')
  .then((status) => {
    res.json(status);
  });

Remove Bucket

const kilatstorage = require('s3-kilatstorage');
kilatstorage.removeBucket('bucket-name')
  .then((status) => {
    res.json(status);
  });

Get all bucket

const kilatstorage = require('s3-kilatstorage');
kilatstorage.listBuckets()
  .then((list) => {
    res.json(list);
  });

Get all object

const kilatstorage = require('s3-kilatstorage');
kilatstorage.listAllObject()
  .then((list) => {
    res.json(list);
  });

Put object with private access file

const kilatstorage = require('s3-kilatstorage');
kilatstorage.putObjectPrivate('path-file', 'bucket-name')
  .then((privateUrl) => {
    res.json(privateUrl);
  });

Put object with public access file

const kilatstorage = require('s3-kilatstorage');
kilatstorage.putObjectPublic('path-file', 'bucket-name')
  .then((publicUrl) => {
    res.json(publicUrl);
  });

Synchronized folder to bucket

const kilatstorage = require('s3-kilatstorage');
kilatstorage.syncFolder('bucket-path', 'path-folder')
  .then();

Download object

const kilatstorage = require('s3-kilatstorage');
kilatstorage.downloadObject('bucket-path', 'local-path-directory')
  .then((status) => {
    res.json(status);
  });

Remove object

const kilatstorage = require('s3-kilatstorage');
kilatstorage.removeObject('bucket-path')
  .then((status) => {
    res.json(status);
  });

List object

const kilatstorage = require('s3-kilatstorage');
kilatstorage.listObject('bucket-name')
  .then((list) => {
    res.json(list);
  });

Check object existing

const kilatstorage = require('s3-kilatstorage');
kilatstorage.existsObject('bucket-name', 'file-name')
  .then((status) => {
    res.json(status);
  });

Show info disk usage for all

const kilatstorage = require('s3-kilatstorage');
kilatstorage.diskUsage()
  .then((list) => {
    res.json(list);
  });

Show info disk usage for single bucket

const kilatstorage = require('s3-kilatstorage');
kilatstorage.diskUsage('bucket-name')
  .then((list) => {
    res.json(list);
  });