0.4.0 • Published 5 months ago

@rocketmakers/storage-aws v0.4.0

Weekly downloads
53
License
MIT
Repository
github
Last release
5 months ago

@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.)

Supabase

If you are wanting to connect to the Supabase Storage bucket via AWS S3, then you can do so with the following config

/ Configuration for aws
const awsConfig: IAwsConfig = {
  region: 'your-aws-region',
  accessKeyId: 'your-access-key-id',
  secretAccessKey: 'your-secret-access-key',
  endpoint: 'https://<<SUPABASE_PROJECT_REF>>.supabase.co/storage/v1/s3',
  forcePathStyle: true,
};

// Storage configuration
const storageConfig: IS3StorageConfig = {
  aws: awsConfig,
  bucketName: 'your-s3-bucket-name',
};

You will need to setup access following the supabase instructions.

0.4.0

5 months ago

0.3.1

11 months ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

5 years ago

0.1.6

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago