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

node-minio

v1.0.2

Published

Async Minio(S3 compatible high performance object storage and retrieval) client for promises support in NodeJS

Downloads

43

Readme

Node-Minio

Async Minio(S3 compatible high performance object storage and retrieval) client for promises support in NodeJS An helper library which provides core promisified helper functions for using minio bucket from Node API

Want to contribute to Node-Minio? Please read CONTRIBUTING.md.

Installation

Node-Minio supports stable versions of Node.js 8.11.0 and later. You can install Node Minio in your project's node_modules folder.

To install the latest version on npm locally and save it in your package's package.json file:

npm install --save node-minio

Usage

  • Initialize Minio Object
  const NodeMinio = require('node-minio');
 
  const config = {
      minio: {
        endPoint: "192.168.23.100",
        accessKey: "SN8JBGY43WPMFT0R56fsdfdsf",
        secretKey: "fdfdfdfd+3R9e/x4V0F6Xpjtfdsfd",
        secure: false,
        port: 8000,
      },
      errorFileUrl: "/sample/errorfile.pdf",
      bucket: "sample"     
  }
 
  const Minio = new NodeMinio(config);
  • Upload a base64 file to Minio Bucket using NodeJS
  async function uploadFile(file) {
      const { base64: base64String, filename } = file;
      const extension = filename.split('.').pop();
      const fileName = moment().format('YYYY_MM_DD_hh_mm_ss_a');
      const object = `sampleFile/${fileName}.${extension}`;
 
      await Minio.base64Upload({ object, base64String });
      return object;
  }
  • Generate dynamic URL with expiry to access file from bucket
   
    async function viewFile(fileName) {
       const filePath= 'sampleFile/${fileName}.pdf'
       const url = await Minio
        .viewLink({
          object: filePath,
        }, false);
      return url;
    }
  • Lists all the directories in current folder/bucket
    async function listFilesList() {
       const baseUrl= 'sampleFile/'
       const fileList = await Minio
        .listDirectoryObjects({ object: baseUrl });
      return fileList;
    }
  • Download a file from bucket
    async function downloadFile(req, res, name) {
            const file = {
                object: 'sampleFiles/',
                name: `${name}_${
                  moment().format('YYYY-DD-MM')}.${ext}`,
              };
             
            return Minio.downloadLinkBase(file)
                .then(downloadLink => res.redirect(downloadLink));
}
  • Validate bucket and Download a file from bucket
    async function ValidateAndDownloadFile(req,res,name) {
            const file = {
                object: 'sampleFiles/',
                name: `${name}_${
                  moment().format('YYYY-DD-MM')}.${ext}`,
              };
             
            return Minio.downloadLink(file)
                .then(downloadLink => res.redirect(downloadLink));
}
  • Used to retry alternative file to be downloaded. Here in tha example below we dont get original file than we search for -rst file and try download it
    async function retryFileFromMinio(fileName) {
       const retryObject = fileName.path.toLowerCase();
       const name = `${fileName}.pdf`.replace(/ /g, '_');
      
     const url = await Minio
      .retryDownloadLink({
      name,
      retryObject,
      object: retryObject.replace(/\.pdf$/g, '-rst.pdf'),
    });
}
  • Generates and returns presigned URL for HTTP PUT operations. Clients may point to this URL to upload objects directly to a bucket even if it is private. This presigned URL can have an associated expiration time in seconds after which the URL is no longer valid. The default value is 7 days.
    async function getUploadLink() {
           const url = await Minio
            .uploadLink({});
          return url;
}
  • Uploads base64 file from temp path(specified path) to bucket
    async function uploadFromTemp(file) {
           const extension = (file.name || file.filename).split('.').pop().toLowerCase();
                     minioObject = {
                       base64String: file.base64,
                       temp: file.path,
                       object: `sample/${Id}/${Id
                       }_${moment().format('DD-MM-YYYY_hh-mm-ss-a')}.${extension}`,
                     };
               const out = await Minio
                .uploadTemp(minioObject);
               return out;
}
  • Uploads multiple base64 file in one go
  return Minio.base64UploadMulti(minioObjects);
  • Copies file from one bucket to another
  return Minio.customCopyObject(minioObject);
  • Gets object from minio bucket as a stream
  return Minio.getFileStream(minioObject);

Documentation

License

Node-Minio is copyright (c) 2019-present Darshit Vora [email protected] and the contributors to Node-Minio.

Node-Minio is free software, licensed under the MIT License. See the LICENSE file for more details.