@rocketmakers/storage-aws
v0.3.1
Published
This package provides a convenient interface for interacting with AWS S3 storage. It wraps the AWS SDK, offering simplified methods for common storage operations.
Downloads
5,007
Keywords
Readme
@rocketmakers/storage-aws - AWS
This package provides a convenient interface for interacting with AWS S3 storage. It wraps the AWS SDK, offering simplified methods for common storage operations.
Installation
To use this package, install it via npm:
npm install @rocketmakers/storage-aws
yarn add @rocketmakers/storage-aws
pnpm add @rocketmakers/storage-aws
Usage
Below is an example of how to use the S3Storage
class in your application:
import { S3Storage, IAwsConfig, IS3StorageConfig } from '@rocketmakers/storage-aws';
// Configuration for aws
const awsConfig: IAwsConfig = {
region: 'your-aws-region',
accessKeyId: 'your-access-key-id',
secretAccessKey: 'your-secret-access-key',
};
// Storage configuration
const storageConfig: IS3StorageConfig = {
aws: awsConfig,
bucketName: 'your-s3-bucket-name',
};
// Create an instance of S3Storage
const s3Storage = new S3Storage(storageConfig);
// Example: Validate storage
const validationResult = await s3Storage.validate();
console.log('Storage validation result:', validationResult);
// Example: Copy a file
const fromFilePath = 'path/to/source/file.txt';
const toFilePath = 'path/to/destination/file.txt';
const copyResult = await s3Storage.fileCopy(fromFilePath, toFilePath);
console.log('File copy result:', copyResult);
// ... Other operations (delete, read, create, etc.)