@yemreak/aws-s3
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

@yemreak/aws-s3

Features

  • Upload Files: Upload files directly to AWS S3.
  • Buffer Uploads: Supports uploading from memory buffers.
  • MIME Type Detection: Automatically determines the MIME type of files.
  • Access Control: Configure files as public or private.
  • URL Construction: Generates accessible URLs for stored files.

Installation

npm install @yemreak/aws-s3

Usage

Initialize Client

import { S3Client } from "@yemreak/aws-s3";

const s3Client = new S3Client({
  bucketName: "your-bucket-name",
  region: "your-region",
  credentials: {
    accessKeyId: "your-access-key-id",
    secretAccessKey: "your-secret-access-key"
  }
});

Upload a File

const filepath = "/path/to/your/file.txt";
s3Client.uploadFile({ filepath, isPublic: true });

Upload a Buffer

const buffer = Buffer.from("your file content");
const filename = "file.txt";
s3Client.uploadBuffer({ buffer, filename, isPublic: false });

Construct a URL

const url = s3Client.constructUrl("file.txt");
console.log(url);

Contributing

Contributions are welcome. Please open an issue or submit a pull request with your changes.

License

Licensed under the Apache License.

Readme

Keywords

Package Sidebar

Install

npm i @yemreak/aws-s3

Weekly Downloads

0

Version

1.0.5

License

ISC

Unpacked Size

18 kB

Total Files

9

Last publish

Collaborators

  • yemreak