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 🙏

© 2026 – Pkg Stats / Ryan Hefner

multi-cloud-storage-lib

v1.0.2

Published

A unified interface for AWS S3, Azure Blob Storage, and Google Cloud Storage with factory pattern support

Readme

multi-cloud-storage-lib

A unified interface for AWS S3, Azure Blob Storage, and Google Cloud Storage with factory pattern support.

Installation

npm install multi-cloud-storage-lib

Features

  • Multi-Cloud Support: AWS S3, Azure Blob Storage, and Google Cloud Storage
  • Factory Pattern: Automatic provider detection and service creation
  • Unified API: Same interface for all cloud storage providers
  • Path Detection: Auto-detect provider from path (s3://, azure://, gs://)
  • TypeScript Ready: Full TypeScript support (coming soon)

Supported Providers

  • AWS S3 (s3://, aws)
  • Azure Blob Storage (azure://, az://, azure)
  • Google Cloud Storage (gs://, gcp://, gcp, gcs, google)

Quick Start

Basic Usage

const { CloudStorageFactory } = require('multi-cloud-storage-lib');

// Auto-detect provider from path
const path = 's3://my-bucket/path/to/file.csv';
const provider = CloudStorageFactory.getProviderFromPath(path);

// Configuration
const config = {
  credentials: {
    accessKey: 'your-access-key',
    secretKey: 'your-secret-key',
  },
  region: 'us-east-1',
};

// Create storage service
const storage = CloudStorageFactory.createStorageService(provider, config);

// Validate authentication
const authResult = await storage.validateAuthentication();
console.log(authResult); // { status: 'success', message: 'Authentication verified' }

// Get object
const content = await storage.getObject('s3://my-bucket/path/to/file.csv');

// List objects
const objects = await storage.listObjects('s3://my-bucket/path/');

Configuration

AWS S3

const config = {
  provider: 's3', // or 'aws'
  credentials: {
    accessKey: 'your-access-key-id',
    secretKey: 'your-secret-access-key',
  },
  region: 'us-east-1',
};

Azure Blob Storage

const config = {
  provider: 'azure',
  credentials: {
    // Option 1: Connection string
    connectionString: 'DefaultEndpointsProtocol=https;AccountName=...',
    
    // Option 2: Account name and key
    accountName: 'your-account-name',
    accountKey: 'your-account-key',
  },
};

Google Cloud Storage

const config = {
  provider: 'gcp',
  credentials: {
    // Option 1: Service account key file path
    keyFilename: '/path/to/service-account-key.json',
    
    // Option 2: Service account credentials object
    projectId: 'your-project-id',
    clientEmail: '[email protected]',
    privateKey: '-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n',
  },
};

API Reference

CloudStorageFactory

createStorageService(provider, config)

Creates a storage service instance for the specified provider.

Parameters:

  • provider (string): Storage provider ('s3', 'aws', 'azure', 'gcp', 'gcs', 'google')
  • config (object): Provider-specific configuration

Returns: Storage service instance

getProviderFromPath(path)

Detects the storage provider from a path string.

Parameters:

  • path (string): Storage path (e.g., 's3://bucket/path', 'azure://container/path')

Returns: Provider name string or null

CloudStorageInterface

All storage services implement this interface:

validateAuthentication()

Validates authentication credentials.

Returns: Promise<Object> with { status: 'success'|'failed', message?: string, error?: string }

getObject(filePath)

Retrieves an object from storage.

Parameters:

  • filePath (string): Full path to the file (e.g., 's3://bucket/path/file.txt')

Returns: Promise<string> - File content as string

listObjects(path)

Lists objects in a storage path.

Parameters:

  • path (string): Storage path to list

Returns: Promise<Array> - Array of object metadata

parsePath(path) (static)

Parses a storage path into bucket/container and file path.

Parameters:

  • path (string): Storage path

Returns: Object with { containerName, bucketName, path }

Examples

Example 1: AWS S3

const { CloudStorageFactory } = require('multi-cloud-storage-lib');

const config = {
  credentials: {
    accessKey: process.env.AWS_ACCESS_KEY_ID,
    secretKey: process.env.AWS_SECRET_ACCESS_KEY,
  },
  region: 'us-east-1',
};

const storage = CloudStorageFactory.createStorageService('s3', config);
const content = await storage.getObject('s3://my-bucket/data/file.csv');

Example 2: Azure Blob Storage

const { CloudStorageFactory } = require('multi-cloud-storage-lib');

const config = {
  credentials: {
    accountName: process.env.AZURE_ACCOUNT_NAME,
    accountKey: process.env.AZURE_ACCOUNT_KEY,
  },
};

const storage = CloudStorageFactory.createStorageService('azure', config);
const content = await storage.getObject('azure://my-container/data/file.csv');

Example 3: Google Cloud Storage

const { CloudStorageFactory } = require('multi-cloud-storage-lib');

const config = {
  credentials: {
    keyFilename: './service-account-key.json',
  },
};

const storage = CloudStorageFactory.createStorageService('gcp', config);
const content = await storage.getObject('gs://my-bucket/data/file.csv');

Example 4: Auto-detect Provider

const { CloudStorageFactory } = require('multi-cloud-storage-lib');

const path = 's3://my-bucket/path/to/file.csv';
const provider = CloudStorageFactory.getProviderFromPath(path); // Returns 's3'

const config = {
  credentials: {
    accessKey: process.env.AWS_ACCESS_KEY_ID,
    secretKey: process.env.AWS_SECRET_ACCESS_KEY,
  },
  region: 'us-east-1',
};

const storage = CloudStorageFactory.createStorageService(provider, config);
const content = await storage.getObject(path);

Path Formats

Supported path formats:

  • AWS S3: s3://bucket-name/path/to/file
  • Azure Blob: azure://container-name/path/to/file or az://container-name/path/to/file
  • Google Cloud: gs://bucket-name/path/to/file or gcp://bucket-name/path/to/file

Error Handling

All methods throw errors that should be caught:

try {
  const content = await storage.getObject('s3://bucket/nonexistent.txt');
} catch (error) {
  console.error('Failed to get object:', error.message);
}

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.