Skip to content

Server: Store S3 files through aws-lite - #646

Merged
lehni merged 1 commit into
mainfrom
refactor/s3-aws-lite
Oct 25, 2026
Merged

lehni merged 1 commit into
mainfrom
refactor/s3-aws-lite

Conversation

@lehni

@lehni lehni commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

S3 storages use @aws-lite/client and @aws-lite/s3 (0.4 MB, 3 packages) instead of @aws-sdk/client-s3, @aws-sdk/lib-storage and the multer-s3 fork (19 MB, 37 packages, plus a git dependency).

  • Config: the s3 config keeps its shape (endpoint, region, credentials). Credentials are always passed explicitly, so nothing is read from the environment or ~/.aws. SDK-only options like forcePathStyle are listed as unsupported.
  • Upload: one upload function for uploads and _addFile(). Streams go through our own multipart loop (8 MB parts, at least one part, aborted on errors) until aws-lite releases its S3.Upload() fix (fix(s3): Fix Upload request params, buffer and empty bodies, and memory use aws-lite/aws-lite#222). Buffers go through one PutObject.
  • Engine: our own small multer engine replaces the multer-s3 fork.
  • Options: acl, cacheControl, contentDisposition, contentEncoding, storageClass, serverSideEncryption and sseKmsKeyId are strings only, and now also apply to files the server adds. The callback forms are gone.
  • URLs: dito builds the URLs itself, from url or from the bucket and endpoint.

Tests use aws-lite's own testing mode, so the real client builds every request. Checked against Exoscale with lineto's development bucket: setup, URLs, a 12 MB stream of unknown length, type detection, buffers, listing and removal pass. The empty-stream case uploads fine; Exoscale only adds charset=UTF-8 to text/plain, as with the AWS SDK.

Behaviour changes for apps: install @aws-lite/client and @aws-lite/s3 instead of the AWS packages; callback forms of the upload options are removed. lineto uses neither.

@lehni
lehni marked this pull request as ready for review October 25, 2026 00:32
Replace the AWS SDK and multer-s3 with @aws-lite/client and @aws-lite/s3 as optional peers, keeping the shape of the `s3` config.

- Require region and credentials, so aws-lite never falls back to the environment or ~/.aws
- Upload streams in 8 MB parts with our own loop until aws-lite releases its S3.Upload() fix, and buffers in one PutObject
- Use our own multer storage engine, with the object options as strings that apply to all stored files
- Build file urls from the bucket and endpoint without config.url
@lehni
lehni force-pushed the refactor/s3-aws-lite branch from 476f5bb to 3e1c36d Compare October 25, 2026 00:36
@lehni
lehni enabled auto-merge (rebase) October 25, 2026 00:37
@lehni
lehni merged commit d634019 into main Oct 25, 2026
8 checks passed
@lehni
lehni deleted the refactor/s3-aws-lite branch October 25, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant