Socket
Socket
Sign inDemoInstall

md-tiny-storage-client

Package Overview
Dependencies
2
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    md-tiny-storage-client

Tiny node client to request distributed AWS S3 or the OpenStack Swift Object Storage.


Version published
Weekly downloads
8
increased by14.29%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Tiny client for distributed S3/Swift storages

GitHub release (latest by date) Documentation

High availability, Performances, and Simplicity are the main focus of this tiny Node client to request AWS S3 API or the OpenStack Swift Object Storage API. It was initially made to request OVHCloud, but it can be used for any Server/Cloud provider.

Highlights

  • 🦄 Simple to use - Only 10 methods: uploadFile, downloadFile, deleteFile, listFiles, listBuckets, headBucket, setFileMetadata, getFileMetadata, deleteFiles and request for custom requests.
  • 🚀 Performances - Vanilla JS + Only 2 dependencies rock-req as HTTP client and aws4 for signing S3 requests.
  • 🌎 High availability - Provide one or a list of storages credentials: the SDK will switch storage if something goes wrong (Server/DNS not responding, timeout, error 500, too many redirection, authentication error, and more...). As soon as the main storage is available, the SDK returns to the main storage
  • Reconnect automatically - If a request fails due to an authentication token expiration, the SDK fetches a new authentication token and retry the initial request with it (Concerns only Swift Storage).
  • 100% tested - Production battle-tested against hundreds of TBs of file uploads, downloads and deletes
  • 👉 Convert XML/JSON responses to JS - XML/JSON responses are automatically converted into Objects/Arrays (Concerns only: listFiles, listBuckets and Errors).
  • 🚩 Mixing S3 and Swift credentials is not supported - When initialising the Tiny SDK client, provide only a list of S3 or a list of Swift credentials, switching from one storage system to another is not supported.

Getting Start

Install and setup in less than 2 minutes:

Supported Methods

Swift APIS3 APIMethodDescription
exampleexampleuploadFileUpload a file from a Buffer or file absolute path.
exampleexampledownloadFileDownload a file as Buffer or Stream
exampleexampledeleteFileDelete a file
exampleexampledeleteFilesBulk delete files (1000 max/per request)
exampleexamplelistFilesList files (1000 max/per requests) use query parameters for pagination
exampleexamplegetFileMetadataFetch custom metadatas
exampleexamplesetFileMetadataSet custom file metadatas
exampleexampleheadBucketDetermine if a bucket exists and you have permission to access it
exampleexamplelistBucketsReturns a list of all buckets owned by the authenticated sender of the request.
exampleexamplerequestCreate custom requests
exampleconnectionConnection is required only for Openstack Swift Object storage to get a unique auth token
exampleexampleBucket AliasSimplify requests by using bucket alias

S3 Example

The following exemple is an initialisation of the SDK client with a list of S3 credentials and a request to download a file. If something goes wrong when downloading the file, the SDK will switch storage and retry to download with the second credentials. As soon as the first storage is available, the SDK returns to the main storage

const storageClient = require('tiny-storage-client');

const s3storage = storageClient([{
    accessKeyId    : 'accessKeyId',
    secretAccessKey: 'secretAccessKey',
    url            : 's3.gra.io.cloud.ovh.net',
    region         : 'gra'
  },
  {
    accessKeyId    : 'accessKeyId',
    secretAccessKey: 'secretAccessKey',
    url            : 's3.eu-west-3.amazonaws.com',
    region         : 'eu-west-3'
  }])

s3storage.downloadFile('bucketName', 'filename.pdf', (err, resp) => {
  if (err) {
    return console.log("Error on download: ", err);
  }
  /**
   * Request reponse:
   * - resp.body => downloaded file as Buffer
   * - resp.headers
   * - resp.statusCode
   */
})

Run tests

Install

$ npm install

To run all the tests:

$ npm run test

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

Supporters

This packaged in maintained by Carbone:

Carbone.io logo

Keywords

FAQs

Last updated on 27 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc