0.4.0 • Published 5 months ago
@rocketmakers/storage-azure v0.4.0
@rocketmakers/storage-azure
This package facilitates interaction with Azure Storage. The package includes an AzureStorage class that implements the IStorage interface, providing a seamless way to perform various operations on files stored in Azure Storage. The class supports functionalities such as copying, deleting, reading, creating files, and handling chunked uploads, making it a powerful tool for managing your storage needs.
Installation
To use this package, install it via npm:
npm install @rocketmakers/storage-azureyarn add @rocketmakers/storage-azurepnpm add @rocketmakers/storage-azureUsage
Below is an example of how to use the AzureStorage class in your Node.js application:
import { AzureStorage, IAzureConfig, IAzureStorageConfig } from '@rocketmakers/storage-azure';
// Configuration for Azure Storage
const azureConfig: IAzureConfig = {
connectionString: 'your-azure-connection-string',
};
// Storage configuration
const storageConfig: IAzureStorageConfig = {
azure: azureConfig,
containerName: 'your-container-name',
};
// Create an instance of AzureStorage
const azureStorage = new AzureStorage(storageConfig);
// Example: Validate storage
const validationResult = await azureStorage.validate();
console.log('Storage validation result:', validationResult);
// Example: Copy a file
const fromFilePath = 'source-file.txt';
const toFilePath = 'destination-file.txt';
const copyResult = await azureStorage.fileCopy(fromFilePath, toFilePath);
console.log('File copy result:', copyResult);
// ... Other operations (delete, read, create, etc.)