Azure Blob Utility (azureBlob.ts)¶
The Azure Blob utility provides functions for interacting with Azure Blob Storage for document and asset management.
Overview¶
lib/azureBlob.ts implements Azure Blob Storage operations for file handling and storage management.
Features¶
- File upload
- File download
- Blob management
- Access control
- Error handling
- Progress tracking
API Reference¶
Upload Functions¶
async function uploadFile(file: File, container: string): Promise<string>
async function uploadBlob(data: Blob, name: string): Promise<string>
async function uploadStream(stream: ReadableStream): Promise<string>
Download Functions¶
async function downloadFile(url: string): Promise<Blob>
async function downloadToStream(url: string): Promise<ReadableStream>
async function getSignedUrl(path: string): Promise<string>
Management Functions¶
async function deleteBlob(url: string): Promise<void>
async function listBlobs(container: string): Promise<BlobItem[]>
async function getBlobMetadata(url: string): Promise<BlobMetadata>
Integration¶
Configuration¶
interface BlobConfig {
accountName: string;
containerName: string;
sasToken: string;
endpoint: string;
}
Usage Example¶
const blobService = new BlobService(config);
// Upload file
const url = await blobService.uploadFile(file, 'documents');
// Download file
const blob = await blobService.downloadFile(url);
// Delete file
await blobService.deleteBlob(url);
Error Handling¶
- Error Types
- Connection errors
- Authentication errors
- Storage errors
- Quota errors
-
Permission errors
-
Recovery
- Retry logic
- Fallback options
- Error reporting
- User feedback
Performance¶
- Optimizations
- Chunked upload
- Stream handling
- Cache strategy
-
Compression
-
Best Practices
- Batch operations
- Connection pooling
- Resource cleanup
- Memory management
Security¶
- Authentication
- SAS tokens
- Access keys
- Role-based access
-
IP restrictions
-
Data Protection
- Encryption
- Secure transfer
- Access logging
- Audit trails
Related Utilities¶
fetcher- HTTP clientutils- Common utilitiesserverAuth- Authentication
Notes¶
- Connection handling
- Error recovery
- Performance tuning
- Security best practices
- Resource management