npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@constructive-io/s3-utils

v2.35.1

Published

Unified S3 utilities — client factory, file operations, presigned URLs

Readme

s3-utils

Unified S3 utilities for the Constructive ecosystem — client factory, file operations, presigned URLs, and bucket management. Built on AWS SDK v3 with support for multiple S3-compatible providers.

Features

  • Multi-provider support — AWS S3, RustFS (or any S3-compatible store), MinIO, Cloudflare R2, Google Cloud Storage, DigitalOcean Spaces
  • Presigned URLs — generate secure PUT and GET URLs with configurable expiry
  • File operations — streaming upload, download, existence checks, and metadata retrieval
  • Bucket management — create buckets with provider-appropriate policies and CORS
  • AWS SDK v3 — modern, modular SDK with tree-shaking support

Installation

npm install @constructive-io/s3-utils

Quick Start

import {
  createS3Client,
  presignPutUrl,
  presignGetUrl,
  upload,
  download,
} from '@constructive-io/s3-utils';

// 1. Create a client
const client = createS3Client({
  provider: 'minio',
  region: 'us-east-1',
  endpoint: 'http://rustfs:9000',
  accessKeyId: 'constructive',
  secretAccessKey: 'constructive-dev-secret',
});

// 2. Upload a file via stream
import { createReadStream } from 'fs';

const result = await upload({
  client,
  bucket: 'my-bucket',
  key: 'docs/report.pdf',
  contentType: 'application/pdf',
  readStream: createReadStream('/path/to/report.pdf'),
});

// 3. Generate a presigned download URL
const url = await presignGetUrl(client, {
  bucket: 'my-bucket',
  key: 'docs/report.pdf',
});

API

createS3Client(config)

Creates an S3Client with provider-specific defaults.

import { createS3Client } from '@constructive-io/s3-utils';

const client = createS3Client({
  provider: 'r2',
  region: 'auto',
  endpoint: 'https://account.r2.cloudflarestorage.com',
  accessKeyId: 'KEY',
  secretAccessKey: 'SECRET',
});

StorageConnectionConfig

| Field | Type | Required | Description | |---|---|---|---| | provider | 's3' \| 'minio' \| 'rustfs' \| 'r2' \| 'gcs' \| 'spaces' | yes | Storage provider | | region | string | yes | S3 region (e.g. "us-east-1") | | endpoint | string | non-AWS | Endpoint URL (required for all providers except s3) | | accessKeyId | string | yes | Access key ID | | secretAccessKey | string | yes | Secret access key | | forcePathStyle | boolean | no | Override path-style URL behavior |

Path-style URLs are enabled automatically for minio, rustfs, r2, and gcs. Virtual-hosted style is used for s3 and spaces.

Throws S3ConfigError on invalid configuration.

presignPutUrl(client, options)

Generates a presigned PUT URL for uploading. The URL is locked to the specified key, content type, and content length.

const url = await presignPutUrl(client, {
  bucket: 'my-bucket',
  key: 'uploads/photo.jpg',
  contentType: 'image/jpeg',
  contentLength: 102400,
  expiresIn: 900, // default: 900 (15 min)
});

presignGetUrl(client, options)

Generates a presigned GET URL for downloading. Supports an optional filename for Content-Disposition.

const url = await presignGetUrl(client, {
  bucket: 'my-bucket',
  key: 'uploads/photo.jpg',
  expiresIn: 3600, // default: 3600 (1 hour)
  filename: 'photo.jpg', // optional, triggers download prompt
});

headObject(client, bucket, key)

Checks if an object exists and returns its metadata. Returns null if the object is not found.

const meta = await headObject(client, 'my-bucket', 'uploads/photo.jpg');
// { contentType: 'image/jpeg', contentLength: 102400 } or null

fileExists({ client, bucket, key })

Returns true if the object exists, false otherwise.

const exists = await fileExists({ client, bucket: 'my-bucket', key: 'doc.pdf' });

upload({ client, bucket, key, readStream, contentType })

Streams a file to S3 using multipart upload.

import { createReadStream } from 'fs';

const result = await upload({
  client,
  bucket: 'my-bucket',
  key: 'uploads/video.mp4',
  contentType: 'video/mp4',
  readStream: createReadStream('/path/to/video.mp4'),
});
// { Location, ETag, Bucket, Key }

download({ client, bucket, key, writeStream })

Downloads an object from S3 and pipes it to a writable stream.

import { createWriteStream } from 'fs';

await download({
  client,
  bucket: 'my-bucket',
  key: 'uploads/video.mp4',
  writeStream: createWriteStream('/tmp/video.mp4'),
});

uploadThrough({ client, bucket, key, contentType })

Returns a PassThrough stream that uploads to S3 as data is written. Emits an 'upload' event with the result when complete.

const pass = uploadThrough({
  client,
  bucket: 'my-bucket',
  key: 'stream-data.csv',
  contentType: 'text/csv',
});

pass.on('upload', (result) => {
  console.log('Upload complete:', result.Location);
});

someReadable.pipe(pass);

createS3Bucket(client, bucket, options)

Creates a bucket with provider-appropriate policies and CORS configuration.

  • Path-style S3-compatible (minio, covering RustFS and MinIO): read-only public access policy (list + get)
  • RustFS/S3/GCS: full-access policy with CORS rules for browser uploads
const { success } = await createS3Bucket(client, 'my-bucket', {
  provider: 'minio',
});

Returns { success: true } if the bucket was created or already exists.

Related Packages

| Package | Description | |---|---| | @constructive-io/s3-streamer | Streaming uploads with automatic content-type detection and metadata extraction | | @constructive-io/etag-stream | ETag generation from streams | | @constructive-io/content-type-stream | Magic-byte content-type detection | | @constructive-io/uuid-hash | Deterministic UUID generation from file content |


Education and Tutorials

  1. 🚀 Quickstart: Getting Up and Running Get started with modular databases in minutes. Install prerequisites and deploy your first module.

  2. 📦 Modular PostgreSQL Development with Database Packages Learn to organize PostgreSQL projects with pgpm workspaces and reusable database modules.

  3. ✏️ Authoring Database Changes Master the workflow for adding, organizing, and managing database changes with pgpm.

  4. 🧪 End-to-End PostgreSQL Testing with TypeScript Master end-to-end PostgreSQL testing with ephemeral databases, RLS testing, and CI/CD automation.

  5. ⚡ Supabase Testing Use TypeScript-first tools to test Supabase projects with realistic RLS, policies, and auth contexts.

  6. 💧 Drizzle ORM Testing Run full-stack tests with Drizzle ORM, including database setup, teardown, and RLS enforcement.

  7. 🔧 Troubleshooting Common issues and solutions for pgpm, PostgreSQL, and testing.

Related Constructive Tooling

📦 Package Management

  • pgpm: 🖥️ PostgreSQL Package Manager for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.

🧪 Testing

  • pgsql-test: 📊 Isolated testing environments with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
  • pglite-test: 🪶 Drop-in pgsql-test replacement backed by PGlite — in-process Postgres, no server required, instance-per-suite isolation.
  • pgsql-seed: 🌱 PostgreSQL seeding utilities for CSV, JSON, SQL data loading, and pgpm deployment.
  • supabase-test: 🧪 Supabase-native test harness preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.
  • graphile-test: 🔐 Authentication mocking for Graphile-focused test helpers and emulating row-level security contexts.
  • pg-query-context: 🔒 Session context injection to add session-local context (e.g., SET LOCAL) into queries—ideal for setting role, jwt.claims, and other session settings.

🧠 Parsing & AST

  • pgsql-parser: 🔄 SQL conversion engine that interprets and converts PostgreSQL syntax.
  • libpg-query-node: 🌉 Node.js bindings for libpg_query, converting SQL into parse trees.
  • pg-proto-parser: 📦 Protobuf parser for parsing PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums.
  • @pgsql/enums: 🏷️ TypeScript enums for PostgreSQL AST for safe and ergonomic parsing logic.
  • @pgsql/types: 📝 Type definitions for PostgreSQL AST nodes in TypeScript.
  • @pgsql/utils: 🛠️ AST utilities for constructing and transforming PostgreSQL syntax trees.

📚 Documentation & Skills

  • constructive-skills: 📖 Platform documentation and AI agent skills — feature catalog, blueprint reference, SDK guides (i18n, billing, limits, events, uploads, security, entities, search, AI), and deployment guides.

Install skills for AI coding agents:

# All platform skills (security, blueprints, codegen, billing, etc.)
npx skills add constructive-io/constructive-skills

# Individual repo skills (pgpm, safegres, testing, CLI, search, etc.)
npx skills add constructive-io/constructive --skill pgpm
npx skills add constructive-io/constructive --skill safegres
npx skills add constructive-io/constructive --skill constructive-testing

Credits

🛠 Built by the Constructive team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on GitHub.

Disclaimer

AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.

No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.