Skip to content

Latest commit

 

History

History
76 lines (53 loc) · 1.88 KB

README.md

File metadata and controls

76 lines (53 loc) · 1.88 KB

S3 Drive

npm version npm downloads License

Wrap common s3 functionality!

This library provide a way to work within a single bucket easily by linking together an s3 instance and a bucket name into a single class.

As with any wrapper, you lose some functionality, however you can always access the s3 instance and any custom configuration, the library re-export all the internal methods with the prefix s3_ so you can use them at will.

This package is ESM only!

This package is for Node 18 and above only!

Install

pnpm i @fixers/s3
npm install @fixers/s3

Usage

The easiest way is to use the S3Drive.

import { s3 } from '@fixers/s3'

const drive = s3({
  publicUrl: 'https//domain/',
  bucket: 'bucket-name',

  // common s3 properties
  region: 'auto',
  credentials: {
    accessKeyId: '',
    secretAccessKey: '',
  },
})

await drive.get('file.txt')

Configure using S3Client

If you prefer to configure s3 by yourself:

import { S3Client } from '@aws-sdk/client-s3'
import { S3Drive } from '@fixers/s3'

const s3 = new S3Client({ })
const drive = new S3Drive(s3, {
  bucket: 'bucket-name',
})