Unified blob storage interface supporting Vercel Blob, Azure Blob Storage, and Azurite
npm install @nir.arad/unified-blob-storageA unified interface for blob storage supporting Vercel Blob, Azure Blob Storage, Azurite, and Google Drive. This package provides a consistent API across different blob storage providers, making it easy to switch between providers or use different providers in different environments.
- ๐ Unified API - Single interface for all supported storage providers
- ๐ Provider Flexibility - Switch between Vercel Blob, Azure Blob Storage, Azurite, and Google Drive
- ๐๏ธ Environment-Based Configuration - Automatic provider selection based on environment variables
- โก Advanced Caching - Hybrid caching with memory and filesystem strategies
- ๐ฏ Smart Cache Selection - Automatic cache strategy based on file type and size
- ๐ง Manual Cache Refresh - Admin-triggered cache updates for static sites
- ๐ Cache Statistics - Comprehensive performance monitoring and metrics
- ๐ฆ TypeScript Support - Full TypeScript definitions included
- ๐งช Comprehensive Testing - 100% test coverage with Jest
- ๐ Well Documented - Complete API documentation and examples
- ๐ง Zero Dependencies - Minimal external dependencies
| Provider | Use Case | Environment |
|----------|----------|-------------|
| Vercel Blob | Production deployments on Vercel | vercel |
| Azure Blob Storage | Enterprise production environments | azure |
| Azurite | Local development and testing | azurite |
| Google Drive | Read-only access to Google Drive files | google-drive |
``bash`
npm install @nir.arad/unified-blob-storage
`typescript
import { UnifiedBlobStorage } from '@nir.arad/unified-blob-storage';
const storage = new UnifiedBlobStorage();
// Fetch files
const content = await storage.fetchFileContent('data/config.json');
const jsonData = await storage.fetchJsonFile('data/galleries/art.json');
// Upload files
await storage.saveFileContent('data/new-file.json', JSON.stringify(data));
// Delete files
await storage.deleteFile('images/category/photo.jpg');
`
- ๐ Quick Start Guide - Get up and running in minutes
- ๐ Implementation Guide - Comprehensive guide with real-world examples
- ๐ง API Reference - Complete API documentation
- โก Advanced Caching - Cached storage features
- ๐ก Examples - Real-world implementation examples
- ๐ฆ Private Publishing - NPM publishing guide
- ๐ Version Updates - Automated version management
For high-performance applications, use the cached storage with automatic strategy selection:
`typescript
import { CachedUnifiedBlobStorage } from '@nir.arad/unified-blob-storage';
const cachedStorage = new CachedUnifiedBlobStorage({
cacheStrategy: 'filesystem', // Default for large files
maxCacheSize: 500 1024 1024, // 500MB
cacheDir: './cache'
});
await cachedStorage.initialize();
// Files are automatically cached based on type and size
const jsonData = await cachedStorage.fetchJsonFile('data/galleries/art.json'); // โ Memory cache
const imageContent = await cachedStorage.fetchFileContent('images/photo.jpg'); // โ Filesystem cache
// Manual cache refresh for static sites
await cachedStorage.refreshAllMetadata();
`
The package automatically detects the storage provider based on environment variables:
`bashFor Vercel Blob
BLOB_PROVIDER=vercel
BLOB_BASE_URL=https://your-blob-url.vercel-storage.com
Development
`bash
Install dependencies
npm installRun tests
npm testBuild package
npm run buildBuild in watch mode
npm run dev
``1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests for new functionality
5. Ensure all tests pass
6. Submit a pull request
MIT License - see LICENSE for details.
- ๐ Documentation
- ๐ Issues
- ๐ฌ Discussions