S3 Upload
Routes Payload CMS upload collections to Amazon S3, pushing the original file and every image size variant.
Installation
pnpm add payload-s3-upload About
This plugin sends files uploaded through Payload CMS upload collections to Amazon S3 instead of the server filesystem. It is built for Payload 1.x and relies on the official `@aws-sdk/client-s3` v3 client, which you pass in (or let it construct from config) when registering the plugin in `payload.config.ts`. Unlike Payload's own cloud storage plugin, configuration lives on each upload collection via an `s3` block inside `upload`. There you set the target `bucket`, an optional `prefix` (static string or a function of the document), and a `commandInput` object whose properties are forwarded to the AWS `PutObjectCommand` and may themselves be functions evaluated at upload time. This makes per-collection concerns such as ACLs or metadata stay with the collection definition rather than the global plugin list. Internally the plugin attaches a `beforeChange` hook that uploads the original file plus every generated image size to S3, and an `afterDelete` hook that removes those same objects when a document is deleted. The `s3` block is stripped from the collection config afterward so Payload's strict upload validation does not reject it. You still own URL generation. The plugin writes objects to S3 and expects you to compute public URLs, for example through an `afterRead` hook or a computed `url` field. Resized variants are uploaded automatically, but mapping their S3 URLs back onto the document is left to your collection hooks.
Package info
- Package name
payload-s3-upload- Latest version
2.1.1- Unpacked size
- 21 kB
- License
- MIT
- Weekly downloads
- 534
- Last publish
- May 16, 2023