Git Product home page Git Product logo

cloud-storage-helper's Introduction

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.

cloud-storage-helper's People

Contributors

harshit1704 avatar hs-kritikal avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.