https://github.com/wefixers/s3
Wrap common s3 functionality
https://github.com/wefixers/s3
s3 signed-url
Last synced: 2 months ago
JSON representation
Wrap common s3 functionality
- Host: GitHub
- URL: https://github.com/wefixers/s3
- Owner: wefixers
- License: mit
- Created: 2023-06-08T10:00:44.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-08T07:46:05.000Z (over 1 year ago)
- Last Synced: 2025-02-26T18:51:35.905Z (3 months ago)
- Topics: s3, signed-url
- Language: TypeScript
- Homepage:
- Size: 86.9 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# S3 Drive
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![License][license-src]][license-href]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.
- [✨ Release Notes](/CHANGELOG.md)
- [Install](#install)
- [Usage](#usage)
- [Configure using S3Client](#configure-using-s3client)> This package is ESM only!
> This package is for Node 18 and above only!
## Install
```sh
pnpm i @fixers/s3
``````sh
npm install @fixers/s3
```## Usage
The easiest way is to use the S3Drive.
```ts
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:
```ts
import { S3Client } from '@aws-sdk/client-s3'
import { S3Drive } from '@fixers/s3'const s3 = new S3Client({ })
const drive = new S3Drive(s3, {
bucket: 'bucket-name',
})
```[npm-version-src]: https://img.shields.io/npm/v/@fixers/s3/latest.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-version-href]: https://npmjs.com/package/@fixers/s3[npm-downloads-src]: https://img.shields.io/npm/dm/@fixers/s3.svg?style=flat&colorA=18181B&colorB=28CF8D
[npm-downloads-href]: https://npmjs.com/package/@fixers/s3[license-src]: https://img.shields.io/npm/l/@fixers/s3.svg?style=flat&colorA=18181B&colorB=28CF8D
[license-href]: https://npmjs.com/package/@fixers/s3