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

cloud-storage-helper

v1.0.1

Published

upload and download operations on Azure Storage and AWS S3

Downloads

5

Readme

Cloud Storage Helper

A Node.js library for easy file upload and download operations on cloud storage services like Azure Storage and AWS S3.

Installation

To install the package, use the following npm command:

npm install cloud-storage-helper

Usage

Use the following code snippets to integrate the cloud-storage-helper into your Node.js project:

const createStorageClient = require('cloud-storage-helper');

// Initialize Azure client
const azureClient = createStorageClient('azure', { /* Azure credentials */ });

// Upload file to Azure
azureClient.upload('containerName', 'blobName', 'filePath')
    .then(result => console.log('Azure Upload Success:', result))
    .catch(error => console.error('Azure Upload Error:', error));

// Download file from Azure
azureClient.download('containerName', 'blobName', 'localFilePath')
    .then(result => console.log('Azure Download Success:', result))
    .catch(error => console.error('Azure Download Error:', error));

// Initialize S3 client
const s3Client = createStorageClient('s3', { /* S3 credentials */ });

// Upload file to S3
s3Client.upload('bucketName', 'objectKey', 'filePath')
    .then(result => console.log('S3 Upload Success:', result))
    .catch(error => console.error('S3 Upload Error:', error));

// Download file from S3
s3Client.download('bucketName', 'objectKey', 'localFilePath')
    .then(result => console.log('S3 Download Success:', result))
    .catch(error => console.error('S3 Download Error:', error));

API Reference

createStorageClient(type, credentials)

Creates a storage client based on the specified type (azure or s3) and provided credentials.

1. Parameters:
    a. type (String): The type of storage client to create ('azure' or 's3').
    b. credentials (Object): The credentials required for the chosen storage type.
    
2. Returns:
    An object with upload and download methods.
upload(containerName, blobName, filePath)

Uploads a file to the specified container/bucket and blob/object in the cloud storage.

1. Parameters:
    a. containerName (String): Azure Storage container name or S3 bucket name.
    b. blobName (String): Azure Storage blob name or S3 object key.
    c. filePath (String): Local path to the file to be uploaded.

2. Returns:
    A Promise that resolves on successful upload.
download(containerName, blobName, localFilePath)

Downloads a file from the specified container/bucket and blob/object in the cloud storage.

1. Parameters:
    a. containerName (String): Azure Storage container name or S3 bucket name.
    b. blobName (String): Azure Storage blob name or S3 object key.
    c. localFilePath (String): Local path to save the downloaded file.

2. Returns:
    A Promise that resolves with the local file path on successful download.

Documentation

For detailed documentation and examples, refer to the official documentation.

License

This project is licensed under the MIT License - see the LICENSE file for details.