npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

md-tiny-storage-client

v3.1.0

Published

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

Downloads

24

Readme

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 API | S3 API | Method | Description | |-------------------------|------------|-------------------|------------------------------------------------------------------------| | ✅ example | ✅ example | uploadFile | Upload a file from a Buffer or file absolute path. | | ✅ example | ✅ example | downloadFile | Download a file as Buffer or Stream | | ✅ example | ✅ example | deleteFile | Delete a file | | ✅ example | ✅ example | deleteFiles | Bulk delete files (1000 max/per request) | | ✅ example | ✅ example | listFiles | List files (1000 max/per requests) use query parameters for pagination | | ✅ example | ✅ example | getFileMetadata | Fetch custom metadatas | | ✅ example | ✅ example | setFileMetadata | Set custom file metadatas | | ✅ example | ✅ example | headBucket | Determine if a bucket exists and you have permission to access it | | ✅ example | ✅ example | listBuckets | Returns a list of all buckets owned by the authenticated sender of the request. | | ✅ example | ✅ example | request | Create custom requests | | ✅ example | ❌ | connection | Connection is required only for Openstack Swift Object storage to get a unique auth token | | ✅ example | ✅ example | Bucket Alias | Simplify 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: