- 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.
npm install @yemreak/aws-s3
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"
}
});
const filepath = "/path/to/your/file.txt";
s3Client.uploadFile({ filepath, isPublic: true });
const buffer = Buffer.from("your file content");
const filename = "file.txt";
s3Client.uploadBuffer({ buffer, filename, isPublic: false });
const url = s3Client.constructUrl("file.txt");
console.log(url);
Contributions are welcome. Please open an issue or submit a pull request with your changes.
Licensed under the Apache License.