1.0.4 • Published 8 months ago

node-aws-s3-client v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

AWS S3 Client for Node.js

NPM Version NPM Bundle Size NPM Downloads

Installation

# npm
npm install node-aws-s3-client

# yarn
yarn add node-aws-s3-client

# pnpm
pnpm add node-aws-s3-client

Usage

import S3Client, { Region } from "node-aws-s3-client";

const s3Client = new S3Client({
  region: Region.EUCentral1, // AWS S3 Region - Required
  credentials: {
    accessKeyId: "accessKeyId", // AWS S3 Access Key Id - Required
    secretAccessKey: "secretAccessKey", // AWS Secret Access Key - Required
  },
  cdnUrl: "https://cdn.example.com", // AWS CDN Url - Required
  defaultBucket: "default-bucket" // AWS S3 Bucket Name - Optional
});

!TIP You can use the setBucket method when you need to change the bucket.

await s3Client.setBucket("bucket-name").delete({ file: "assets/example.jpeg" });

Delete file

await s3Client.delete({ file: "assets/example.jpeg" });

Upload file

// File path
const uploadedFile = await s3Client.upload({
  file: path.join(__dirname, "../example.jpeg"),
  destFile: "assets/example.jpeg",
});

// Buffer
const uploadedFileTwo = await s3Client.upload({
  file: Buffer.from("EXAMPLE", "utf-8"),
  destFile: "assets/example.txt",
});

List files

const files = await s3Client.list({
  path: "assets",
});

Download file

await s3Client.download({
  file: "assets/example.jpeg",
  outFile: path.join(__dirname, "./example.jpeg"),
});
1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago