@rocketmakers/storage-azure
v0.3.1
Published
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 fun
Downloads
7,018
Keywords
Readme
@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-azure
yarn add @rocketmakers/storage-azure
pnpm add @rocketmakers/storage-azure
Usage
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.)