light-s3
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

light-s3

Downloads

Simple and lightweight s3-compatible client.

Features

  • dependencies free 💭
  • low size 🚀
  • typescript support ⚡️

Usage

import { query } from '../lib/index.mjs';

async function myRequestImpl(req) {
  const options = {
    method: req.method,
    headers: req.headers,
  };

  if (req.body) {
    options.body = req.body;
  }

  const response = await fetch(req.url, options);

  return {
    status: response.status,
    body: await response.arrayBuffer()
  };
}

const client = {
  base: process.env.S3_HOST,
  region: process.env.S3_REGION,
  secret: process.env.S3_SECRET,
  keyId: process.env.S3_KEY_ID,
  service: 's3',
  request: myRequestImpl
};

query({
  client,
  method: 'PUT',
  key: '/file.txt',
  buffer: Buffer.from([1, 2, 3])
}).then(console.log);

Readme

Keywords

Package Sidebar

Install

npm i light-s3

Weekly Downloads

1

Version

0.1.5

License

MIT

Unpacked Size

8.87 kB

Total Files

11

Last publish

Collaborators

  • theevolk