Skip to main content
This guide covers upgrading between versions of the Bunny Storage plugin.

v4.0.0-beta.2 to v4.0.0-beta.3

Update Node.js and Payload

Plugin 4.0.0-beta.3 needs Payload 4.0.0-beta.4 or later and Node.js 24.22.1 or later. Payload 4.0.0-beta.4 itself needs Node.js 24.22.1, so update Node.js first. Then update payload, @payloadcms/plugin-cloud-storage, @payloadcms/ui and your other @payloadcms/* packages to 4.0.0-beta.4, the same exact version for all of them:
Also update @payloadcms/next, your database adapter and any other @payloadcms/* package to 4.0.0-beta.4. If you use the media preview plugin, update it to 2.0.0-beta.5 or later with npm install @seshuk/payload-plugin-media-preview@beta. On Postgres and SQLite, Payload 4.0.0-beta.3 changes the unique index of the _locales tables. If you use migrations, run npx payload migrate:create after the update and check the migration. Check the Payload 4.0.0-beta.3 and 4.0.0-beta.4 release notes for the other changes in Payload. The plugin options do not change.

v4.0.0-beta.1 to v4.0.0-beta.2

1. Update Payload to 4.0.0-beta.2

The plugin now needs Payload 4.0.0-beta.0 or later, and with it Next.js >=16.4 <17. Canary builds of Payload are not supported. Update payload, @payloadcms/plugin-cloud-storage, @payloadcms/ui and your other @payloadcms/* packages to 4.0.0-beta.2, the same exact version for all of them. @payloadcms/ui and React 19 (react, react-dom) are new peer dependencies. If you use the media preview plugin, update it to 2.0.0-beta.3 or later with npm install @seshuk/payload-plugin-media-preview@beta. Follow the Payload 4 migration guide for the changes in Payload itself. Payload 4 removed the top-level sharp option. If your config still sets it, Payload stops at startup with The top-level `sharp` config option was removed in Payload 4.0. Remove the option, or run Payload’s codemod:
Payload renamed image sizes to variants. You declare them in sharpTransformer({ collections: { <slug>: { variants } } }) from @payloadcms/transformer-sharp instead of upload.imageSizes, and documents store them under variants instead of sizes. The plugin follows this: thumbnail.sizeName names a variant, and the stored files of each variant are read from variants. With any upload transformer set, Payload sends every /api/<collection>/file/ request through the transformers, which look the file up by document. So the thumbnailURL of a Stream video, with Payload access control on, now points to <routes.api>/storage-bunny/stream/thumbnail/<collection>/<id>/<videoId>/thumbnail.jpg instead of /api/<collection>/file/bunny:stream:<videoId>:thumbnail.jpg. With streamAnimated, both end with preview.webp instead. <routes.api> is the API route of your Payload config, /api by default. The old URL always started with /api. API responses get the new URL on their own, because thumbnailURL is computed on read. Old URLs that you copied somewhere else return 404. Read thumbnailURL again to get the new ones. See Thumbnail URLs. Some plugin options are renamed or merged since beta.1. The plugin throws at startup and names the new key for each old one, for example [@seshuk/payload-storage-bunny] storage.s3.region was removed, use storage.region with storage.s3: true. It also checks every collections.<slug>, even with enabled: false. See Update the renamed options for the details of each change. These changes do not throw an error:
  • A collection stream.tus: true now turns TUS on for that collection. In beta.1, only false or an object was accepted.
  • collections.<slug>: false now leaves the collection out. In beta.1, a collection took options or true.
  • Exports and types ending in Config now end in Options, for example getBunnyConfig() is now getBunnyOptions() and BunnyStorageConfig is now BunnyStorageOptions. TypeScript shows an error for each old name.
  • New options: stream.status, stream.preview (also per collection) and tasks.secret. See Background tasks.

2. Create the migrations

Payload 4.0.0-beta.0 stores image variants under variants instead of sizes. This rename comes from Payload, not from this plugin. Every database needs Payload’s predefined sizes-to-variants migration for it, MongoDB too, even with stream.status: false. Create it first, with the package of your database adapter, for example on Postgres:
On other databases, use your adapter’s package instead, for example @payloadcms/db-sqlite/sizes-to-variants, @payloadcms/db-d1-sqlite/sizes-to-variants or @payloadcms/db-mongodb/sizes-to-variants. Do not replace this step with a plain migrate:create on SQL databases: it drops the sizes_* columns and adds empty variants_* columns, so the stored variants are lost. See the Payload 4 migration guide. Payload 4.0.0-beta.0 also adds the fields for file versions: an original group on each upload collection, and prefix and _objectKey on each image variant. Stream collections now also store the encoding state of each video in bunnyData.stream.status. On Postgres, SQLite and D1, this is a new indexed column (bunny_data_stream_status) on each Stream collection’s table. After the sizes-to-variants migration, create one migration for all these changes, then run both:
If your project already has migrations, the sizes-to-variants migration also writes a new schema snapshot with the renamed columns. The second migrate:create then keeps them and adds the new columns. It also picks up the other schema changes of Payload 4.0.0-beta.0, so check the migration before you run it. On MongoDB, skip the second migrate:create and only run npx payload migrate: the new fields need no migration, and Payload creates the plugin’s index on startup. In development, Payload pushes the new column for you. Run the sizes-to-variants migration first there too: without it, the push can offer to drop the sizes_* columns. On Postgres and SQLite, a database that Payload pushed in development makes npx payload migrate ask It looks like you've run Payload in dev mode, meaning you've dynamically pushed changes to your database. If you'd like to run migrations, data loss will occur. Would you like to proceed? The default is No. Run the command in a terminal to answer it. A script or CI job without a terminal cannot answer, so run your migrations against a database that Payload never pushed to. A collection with versions also gets version_bunny_data_stream_status in its _<slug>_v table. See Database columns for the full list. If you use generated types, regenerate them. bunnyData.stream.status and the bunnyStream admin field are new in the types:
Existing videos have no status at first. In the list, they show Unknown and do not match the Stream Status filter. Saving such a document keeps the empty status. Turn on status sync to fill it: each run asks Bunny for the state of these videos and stores it, at any age. Without status sync, open the document in the admin. The media preview and the Bunny Stream card ask Bunny for the state and store it. To keep the old behavior, set stream.status: false and stream.preview: false. Then the plugin adds no column, and the edit view keeps Payload’s own video and audio player. You still need to regenerate the import map for TUS uploads and for the media preview adapter.

3. Every upload gets its own folder

Payload now manages stored files by their storage key. Every upload through the Payload server or through client uploads goes to a new folder:
<prefix> is the prefix stored on the document. It is the collection prefix, or the document prefix placed under the collection prefix. The processed file and the image variants go to the same folder. The document stores the folder in prefix and _objectKey, and the source file in the original group. Documents from earlier versions keep their keys. Payload starts to manage them the first time their file changes.
  • Client uploads. The stored prefix no longer includes the UUID. The UUID is stored in _objectKey. Documents from beta.1 keep the UUID in prefix. An access rule or query with prefix: { like: 'tenants/acme/' } now matches no new upload, because a new prefix has no trailing slash. Match both shapes with an or of prefix: { equals: 'tenants/acme' } and prefix: { like: 'tenants/acme/' }. See Querying by prefix.
  • Stream. A new video in Bunny is named after the uploaded file, without Payload’s -original suffix. A document saved with a TUS video gets the same fields: its file name is the video title with -original, for example clip-original.mp4.
  • Duplicate names. Payload adds a number to a file name that is already used. Client uploads, also videos from the bulk upload drawer, check the name in the whole collection. TUS saves check it only within the document’s prefix.

4. Replaced files stay while a version uses them

What happens to a replaced file or video now depends on versions. Payload 4 turns versions on for every collection that does not set versions: false, with maxPerDoc: 100.
  • With versions: false, the old file or video is deleted when you replace it, as before.
  • With versions, a replaced file stays in Bunny Storage, and a replaced video stays in your Stream library, while any document or version references it. So restoring a version brings back a working file. It is deleted after its last reference is gone: when you replace the file, delete the document, change a draft, or when Payload removes old versions because of maxPerDoc. For videos, documents and versions in every collection that uses the same library count.
Only operations through Payload delete files and videos. Changes made directly in the database, for example with SQL or payload.db.*, do not. Before, a TUS save deleted the old video right away, unless the published document still used it. payload.renameFile, the rename operation in REST and GraphQL, and restoring a version now copy the stored files to new keys. In S3 mode, the plugin uses S3 CopyObject. Over the HTTP API, it downloads the file and uploads it again through your server. Bunny then sets the Content-Type from the file extension, so a custom type is not kept. Stream videos are not copied: the old and the new key point to the same video. The copy does not overwrite a file that exists at the new key when the copy starts. A rename then fails with 409. A restore fails with a server error instead, because Payload maps only rename collisions to 409. A restore rarely collides, because it gives the file a new name with a random ID. In S3 mode, CopyObject sends If-None-Match: *, so the check is atomic. Over the HTTP API, the plugin checks the key right before the upload. So two requests that copy to the same key at the same time can overwrite each other. See Rename and restore. Payload names the renamed or restored file, not the plugin:
  • A rename adds Payload’s -original suffix to a file that has no variants. Renaming to x.jpg stores x-original.jpg, also in filename.
  • A restore keeps the name of a file that the current document still uses. It copies every other file of the version to a new name with a random ID, for example photo-original-<uuid>.jpg.
  • Replacing the file of a document with a file of the same name adds a number, for example clip-original-1.mp4, because the document itself still uses the old name. The video title in Bunny stays clip.mp4.
Rename can hang on Postgres or PGlite when the database pool has a single connection. This is a Payload issue, see payloadcms/payload#18406.

5. No cache purge on upload

The plugin no longer purges the CDN cache after an upload, because every upload writes a new key. It still purges the plain CDN URL with a trailing * when Payload deletes a file and purge is on. See Cache purge.

6. TUS saves send no file

A collection with TUS now gets upload.filesRequiredOnCreate: false, because the admin saves a video ID instead of a file. The plugin checks the rule itself: a create needs a file or a verified TUS video. Draft saves skip this check. If your collection sets filesRequiredOnCreate: false, the plugin requires neither. Custom TUS clients create or update the document with bunnyData.stream.videoId and bunnyData.stream.videoToken, and no file. tus-auth no longer accepts head and no longer returns filename or signedReceipt. See TUS uploads. tus-auth now creates the TUS upload in Bunny with the declared filesize. It returns uploadUrl, headers and expiresIn instead of authorizationSignature, authorizationExpire and thumbnailTime. Send the file to uploadUrl with PATCH requests and these headers. Do not create an upload with POST to the Bunny TUS endpoint. The headers are valid for expiresIn seconds, at most 5 minutes. For a longer upload, call tus-auth again with videoId, videoToken and renew: true to get new headers for the same upload. In renew mode, tus-auth never creates a video and answers 409 when it cannot renew the upload. stream.tus.expiresIn is now the time that Bunny keeps an unfinished upload. The saved filesize is the size of the upload, and a save before the upload is complete fails with 400. Videos saved from the bulk upload drawer, or from the edit view without TUS mode, still go to Bunny Stream over TUS, but only when Payload does not need to read the whole file. Payload reads the whole file when the collection sets upload.mimeTypes, to check the type. It also reads it when an upload transformer with transformFile handles video, for example with mimeTypes: ['*/*']. The sharpTransformer does not count. In these cases, the plugin does not take these videos:
  • A collection that stores files only in Stream (storage: false) uploads them through your server. Payload’s request size limits apply.
  • A collection with client uploads rejects them with File type "<type>" uploads to Bunny Stream, not through client uploads.
To keep large videos off your server, use TUS mode in the edit view, or remove upload.mimeTypes and limit types with Stream mimeTypes. A document saved this way stores the Bunny video ID as its _objectKey. The plugin creates the TUS upload with the declared file size, so Bunny rejects a larger file. A save before the upload is complete, or with another size, fails with 400. These uploads cannot be cancelled and do not resume. See Bulk uploads and form saves.

7. Webhook writes skip collection hooks

The webhook now writes bunnyData.stream straight to the database, also with stream.status: false, where it only updates resolutions. It no longer runs your collection hooks (beforeChange, afterChange and others), does not create a new version and does not change updatedAt. If a hook of yours reacted to the webhook’s resolutions update, for example to revalidate a page, run that logic another way, for example in a job that reads bunnyData.stream.

8. Regenerate the import map

Stream collections now have a Bunny Stream status field with its own list cell and sidebar components. If you use the media preview, the Bunny Stream adapter also uses its own preview component. Regenerate the import map, or the admin cannot find the components:
Collections with TUS uploads need it too. Their upload area now loads from @seshuk/payload-storage-bunny/rsc, so the edit view shows the collection’s filePreview, for example the media preview, and its custom upload controls (upload.admin.components.controls). The edit view of Stream video and audio files now shows the Bunny Stream player from @seshuk/payload-storage-bunny/client#StreamFilePreview, also without the media preview plugin. It needs the import map too. Set stream.preview: false to keep Payload’s built-in video and audio player.

9. Redeploy the Edge Script

If you use client uploads with an Edge Script (HTTP API zones), redeploy it. The new script answers 503 when its SHARED_SECRET is missing, and 502 with CORS headers when Bunny Storage fails. Until you redeploy, bunny:deploy-edge-script --check reports the script as outdated.
A deploy to an existing script without --secret now keeps its SHARED_SECRET. Before, a deploy with --zones-file replaced it with a new one.

10. One cleanup setting per library

Collections that use the same Stream library must now have the same cleanup setting, also when one of them uses the global stream options. Otherwise the plugin throws at startup with stream library <id> is configured with conflicting `cleanup` options across collections. Turn cleanup on for all of them, or for none, with the same maxAge.

11. Optional: background tasks

You can now run the Stream tasks without Payload jobs, and keep the stored status up to date with the new stream.status.sync task. See Background tasks.

v3 to v4

v4 supports Payload 4. It follows the new storage adapter API, so most changes come from Payload itself. Do steps 1 to 4 first. The later steps only apply to some apps.
Requires Payload 4.0.0-beta.4 or later, Next.js >=16.4 <17 and Node.js 24.22.1 or later. Canary builds of Payload are not supported. Upgrade Node and Payload first. Follow the Payload 4 migration guide for the changes in Payload itself.

1. Update Node and the packages

Payload 4 needs Node.js 24.22.1 or later. Then install v4 of the plugin and its peer dependencies. Use the same exact version for the @payloadcms/* packages and your payload package:
React 19 (react, react-dom) is a peer dependency too. If you use the media preview plugin, update it with npm install @seshuk/payload-plugin-media-preview@beta. Payload 4 removed the top-level sharp option. If your config still sets it, Payload stops at startup. Remove the option, or run Payload’s codemod:
Payload 4 also renamed image sizes to variants. Declare them in sharpTransformer({ collections: { <slug>: { variants } } }) from @payloadcms/transformer-sharp instead of upload.imageSizes. See the Payload 4 migration guide.

2. Register the adapter under storage

Payload 4 does not accept storage adapters in plugins. Move bunnyStorage to the top-level storage array:
payload.config.ts
Payload’s npx @payloadcms/codemod --transform migrate-storage-adapters-to-config codemod only knows the official adapters, so move bunnyStorage by hand.

3. Update the renamed options

Some options are renamed or merged. The plugin throws at startup and names the new key for each old one:
It also checks every collections.<slug>, even with enabled: false. Check these details too:
  • expiresIn function. expiresAt took a UNIX timestamp, but expiresIn reads a number as seconds. Return a Date instead, for example expiresIn: () => eventEndsAt ?? 3600. A number over 10 years throws an error. See Signed URLs.
  • redirect.status. It accepts 302 or 307 only.
  • tus.access. It still replaces the default check. Call defaultAccess() to keep it, for example access: async ({ data, defaultAccess }) => data.filesize < 5e9 && (await defaultAccess()). See TUS uploads.
  • getBunnyStorageForCollection(). It returns s3: true or false and the region in region. Read region, not s3.region.
Some exports are renamed. TypeScript shows an error for each old name: These changes do not throw an error. Check them if they apply to your app:
  • The prefix argument of a urlTransform function is now only the document’s own prefix field. In v3 it also contained the collection prefix. If your function builds a path from prefix, add the collection prefix yourself.
  • A collection thumbnail now keeps the global thumbnail.urlTransform unless it sets its own. In v3, a collection that only set sizeName lost the global transform function.
  • thumbnail.sizeName now names a variant from sharpTransformer({ collections: { <slug>: { variants } } }), not an entry of upload.imageSizes. See Using a named image size.
  • A collection set to false is now left out, together with its hidden prefix field, so the SQL schema changes. In v3, false turned the collection on. To switch the plugin with an environment variable, use enabled.
  • A collection stream.tus: true or stream.tus: { ... } now turns TUS on for that collection, even when the global stream.tus is off. In v3, it was ignored.
  • When a collection sets generateFileURL and signedUrls.userIp is set, the plugin now keeps the generateFileURL result. In v3, it replaced it with an IP-locked signed URL.
  • Cache purge now purges the plain CDN URL with a trailing *. This also clears cached copies with query strings, such as signed or transformed URLs. The plugin purges only when Payload deletes a file, not after an upload, because every upload writes a new key.
  • Payload 4 turns versions on by default. With versions, a replaced file or Stream video stays in Bunny while a document or version references it. Set versions: false to delete it on replace, as before. See Replaced files stay while a version uses them.
  • A collection with TUS gets upload.filesRequiredOnCreate: false, and the plugin checks the rule itself. Videos from the bulk upload drawer go to Bunny Stream over TUS, except when Payload must read the whole file, for example when the collection sets upload.mimeTypes. See TUS saves send no file.
  • With an upload transformer set and Payload access control on, the thumbnailURL of a Stream video now points to <routes.api>/storage-bunny/stream/thumbnail/.... <routes.api> is the API route of your Payload config, /api by default. Old URLs that you copied somewhere else return 404. See Thumbnail URLs.
  • The webhook writes bunnyData.stream straight to the database and no longer runs your collection hooks. See Webhook writes skip collection hooks.

4. Migrate the database

This step applies to every database, MongoDB too. Every upload collection that uses the plugin now has a hidden prefix field. Payload adds it even when the collection has no static prefix, and even when you set enabled: false. This keeps the schema the same in every environment. On Postgres, SQLite and D1, prefix is a new column on each upload collection’s table. Payload also adds a hidden _objectKey field, an original group, and prefix and _objectKey on each image variant. Payload 4.0.0-beta.0 also renames image sizes to variants. So on every database, MongoDB too, first create Payload’s predefined sizes-to-variants migration with the package of your database adapter, as shown in Create the migrations. Then create a migration for the other changes and run both, for example on Postgres:
In development, Payload pushes the schema for you. Run the sizes-to-variants migration first there too: without it, the push can offer to drop the sizes_* columns, and the stored image sizes are lost. On MongoDB, skip the second migrate:create and only run npx payload migrate: the new fields need no migration of their own. The column defaults to the collection’s static prefix, or an empty string, so existing rows keep resolving to the same files. Stream collections also get an indexed bunny_data_stream_status column for the stored encoding state. Payload 4 has more schema changes of its own, such as versions and job fields. The plain migrate:create run covers them all. If your project already has migrations, or runs migrations in CI, read Create the migrations first. Existing videos show Unknown until their status is filled. Turn on status sync, or open the document in the admin. To keep the old behavior, set stream.status: false and stream.preview: false. If you use generated types, run npx payload generate:types. If you use Bunny Stream, run npx payload generate:importmap after the upgrade. Stream collections get a Bunny Stream status field with its own components, and the media preview adapter uses its own preview component. See Regenerate the import map.

5. Redeploy the Edge Script

If you use client uploads with an Edge Script (HTTP API zones), redeploy it after the upgrade:
The new script answers 503 when its SHARED_SECRET is missing. See Redeploy the Edge Script. Payload 4 replaced bin scripts with cli.commands. The plugin registers bunny:deploy-edge-script there for you, so the command itself does not change. It is not available when you set cli: false.

6. Custom upload clients

This step only applies if you wrote your own upload client. The admin UI needs no changes. The plugin’s POST /api/storage-bunny/storage/upload endpoint is removed. Client uploads now use Payload’s shared POST /api/upload-instructions endpoint:
  1. Send { collectionSlug, filename, filesize, mimeType } to POST /api/upload-instructions.
  2. PUT the file to request.url with request.headers from the response.
  3. Send the returned file object unchanged as the file field of the document request. It replaces clientUploadContext.
See Custom upload clients for a version with error handling. For Stream uploads, tus-auth no longer accepts head and no longer returns clientUploadContext. It creates the TUS upload and returns uploadUrl, headers and expiresIn instead of authorizationSignature, authorizationExpire and thumbnailTime. Do not create the upload with POST yourself. Send the file to uploadUrl with PATCH requests, then save the document with bunnyData.stream.videoId and bunnyData.stream.videoToken and no file. See TUS saves send no file and Custom TUS clients.

7. Read errors from errors

Client upload errors now use Payload’s standard error format:
v3 returned { "error": "..." }. Read errors[0].message instead. Some status codes changed too, because Payload now runs its own checks first. For example, a file over upload.limits.fileSize gets 400, and a file type the collection does not accept gets a validation error. Check response.ok rather than exact codes. The tus-auth endpoint already used this format.

8. Every upload has a UUID folder

Payload now stores each upload, from the server or from client uploads, under its own random folder: <prefix>/<uuid>/<name>-original.<ext>. The stored prefix stays the folder you configured, and the UUID is stored in _objectKey. Access rules and queries that match prefix with equals keep working. Files that are already stored keep their path. With versions, a replaced file stays in Bunny while a version uses it. See Replaced files stay while a version uses them.

9. clientUploads.access only narrows

Payload now checks that the user is signed in and has create or update access to the collection before your clientUploads.access function runs. In v3, a custom access function replaced that check. Now it can only make it stricter. If your access function let in users without collection create or update access, for example anonymous visitors, give them that access in the collection’s own access config instead. For example, clientUploads: { access: () => true } no longer allows public uploads.

10. Files at the zone root

This step only applies if you upgrade from v3.1.0 or earlier. v3.1.1 and later already read these files under the collection prefix. If you have not moved them yet, follow v3.1.0 to v3.1.1 first.

11. Stream cleanup schedule

If you set stream.cleanup.schedule.cron, check that it uses Payload 4’s stricter cron syntax. A step must follow * or a range, so write */10, not /10 or 5/10. The default 0 2 * * * is valid. Collections that use the same Stream library must have the same cleanup setting, or the plugin throws at startup. See One cleanup setting per library.

12. Move TUS labels to Payload’s i18n

The plugin’s i18n option is removed. Override the plugin labels in Payload’s own i18n config, under the @seshuk/payload-storage-bunny key:
payload.config.ts
Your values win over the plugin defaults. The TUS upload now sits inside Payload’s file panel, and some labels changed with it. tusUploadChecking, tusUploadFileSize and tusUploadFinalizing are gone, and the status texts are new. See Translations for the current keys.

13. Remove v2 leftovers

  • The @seshuk/payload-storage-bunny/migrations subpath is removed. If you still have v2 data, upgrade to v3 and run the data migration on Payload 3 first.
  • The renamed v2 keys, such as apiKey, adminThumbnail or stream.tus.uploadTimeout, still throw a startup error with the new name. Remove any that are left.

v3.1.1 to v3.1.2

v3.1.2 contains security fixes for Stream TUS uploads. It needs no option changes.
  • tus-auth checks the file like a storage client upload. It rejects a type outside the collection’s upload.mimeTypes or the Stream mimeTypes, a restricted type and a file over upload.limits.fileSize, even when checkAccess allows the request. The saved document gets the signed file size and MIME type.
  • A videoToken is bound to the signed-in user and expires after 24 hours. Tokens from v3.1.1 stop working, so an upload that was paused before the update starts again. The same happens to an upload that stays paused for more than 24 hours.
  • Payload rejects a videoId that another document in a Stream collection of the same library already uses.
If you call tus-auth from your own client, request a new videoToken for each upload and save the document within 24 hours.

v3.1.0 to v3.1.1

v3.1.1 needs no option changes. Most apps are not affected. It only changes documents that have an empty or missing prefix in a collection that sets a prefix. v3.1.0 stored the files of such documents at the root of the storage zone. v3.1.1 reads, deletes and stores them under the collection prefix. Documents with a non-empty prefix keep the same file paths. To check a collection, query it for documents without a prefix:
If the query returns documents, move each file and its image sizes from <file> to <collection prefix>/<file> in the storage zone. Otherwise their URLs return 404. You can move files with any S3 client on an S3 zone, or download and re-upload them in the Bunny dashboard.

v3.0.x to v3.1.0

v3.1.0 needs no option changes, but it has new install and upload requirements. Most apps only need steps 1 and 2. v3.1.0 requires Payload 3.90.2 or later. If you are on v3.0.1 with an older Payload version, upgrade Payload first. Staying on v3.0.1 is not recommended, because it lacks the security fixes in v3.1.0.

1. Install the cloud storage plugin

@payloadcms/plugin-cloud-storage is now a peer dependency. Add it next to the plugin, in the version that matches your Payload version:

2. Redeploy the Edge Script

If you use client uploads with an Edge Script (HTTP API zones), redeploy it:
The new script checks the signed file size and MIME type and does not overwrite existing files. An older script still accepts upload URLs minted by v3.1.0, but it skips these checks. S3 zones do not use the script.

3. Stricter client uploads

The /api/storage-bunny/storage/upload endpoint now has these requirements:
  • Without a custom clientUploads.access function, the user needs create or update access to the collection.
  • filesize is required, next to collectionSlug, filename and mimeType.
  • HTML, JavaScript, SVG and XML files are rejected, unless the collection sets upload.allowRestrictedFileTypes: true.
  • The upload URL only accepts the declared size and MIME type.
  • It returns 409 when a file already exists at the path.
The admin UI already follows these rules. Payload’s own rename logic keeps file names unique, so 409 is rare in practice.

4. Custom upload clients

This step only applies if you wrote your own upload client. The admin UI needs no changes.
  • Client uploads. Send the headers from the upload endpoint response with the PUT. Send the clientUploadContext from the same response unchanged with the document. Payload now requires its signed receipt, and the plugin takes the prefix, file size and MIME type from it.
  • TUS and Stream. tus-auth returns a videoToken with every videoId. Send it as bunnyData.stream.videoToken when you save a document with a videoId, and send videoId with videoToken to resume an upload. Without a valid token, Payload ignores the videoId on save, and tus-auth creates a new video.
  • Stream client uploads. Send the file head as head to tus-auth, and send the returned clientUploadContext unchanged with the document.
  • Read-only fields. The injected prefix field and bunnyData.stream.resolutions no longer accept values from the REST or GraphQL API. Server code that uses the Local API is not affected.
See the API reference for the request and response shapes.

5. Check static plus mint-time prefixes

This step only applies to collections that set both a static prefix and a clientUploads.prefix callback that returns a path outside the static prefix. For example, the static prefix uploads and the callback result tenants/acme. v3.0.x uploaded such files to tenants/acme/<file>, but stored uploads/tenants/acme on the document. So URLs and deletes pointed to a path with no file. v3.1.0 uploads new files to uploads/tenants/acme/<file>, which matches the stored prefix. To fix files uploaded with v3.0.x, move each file (and its image sizes) from <callback result>/<file> to <static prefix>/<callback result>/<file>. You can move files with any S3 client on an S3 zone, or download and re-upload them in the Bunny dashboard. The stored documents need no change. Collections that use only one of the two prefixes are not affected.

v2.x to v3.0

v3 has two independent parts: a set of config changes (which throw at startup until you rename the keys) and a data migration for the stored Stream metadata. Do both.
Coming from v2? Upgrade to v3 first. The data migration helper ships only in v3.x and was removed in v4. Upgrade to v3, run the migration on Payload 3, then follow v3 to v4.
Requires Payload 3.90.2 or later and Node.js 22 or later. Upgrade Payload (and Node, if needed) first if you are below either.
Back up, then run the data migration. Take a database backup first. v3 reads Stream metadata only from the new bunnyData field — until you run the data migration, every existing video looks empty (broken thumbnails, no resolutions, videoId queries return nothing). On Postgres/SQLite the legacy columns are dropped the moment the v3 schema is pushed, so migrate before that. Config renames alone are not enough.

Config changes (breaking)

Several config keys were renamed or removed in v3. Most throw at boot with a targeted message, so a v2 config crashes on startup until you update it. The last three rows are the exception — they produce no boot error (they are a naming convention, silently ignored, or always overridden), but you should still clean them up: Per-service keys are unchanged: storage.apiKey and stream.apiKey stay as they are. New in v3 (optional, nothing to migrate — adopt when you need them):
  • Client uploads — browser-direct uploads, configured under storage.clientUploads (storage.clientUploads: true shorthand, or the full options). There is no mode option — the transport is chosen automatically (presigned S3 when the zone sets storage.s3, otherwise a deployed Edge Script).
  • Per-collection zones and libraries — point a collection at its own storage zone / stream library with full options; the top-level storage/stream become optional.
  • storage.s3 — S3-compatible zone access.
  • stream.referer — Referer header for MP4-fallback and Stream thumbnail requests behind BlockNoneReferrer libraries.
  • Per-collection stream.tus: false — disable TUS for one collection.
  • Stream webhook (stream.webhook) — v2 had no webhook; MP4-fallback resolutions were fetched lazily on the first serve (v3 still does this as a fallback). The optional webhook pre-populates bunnyData.stream.resolutions the moment encoding finishes instead. Set webhook.secret to the library’s Read-Only API key (Bunny signs each callback with the X-BunnyStream-Signature HMAC header) and point your Bunny library’s webhook at /api/storage-bunny/stream/webhook.

What changed (data)

v3 stores Bunny Stream metadata in a single bunnyData group field instead of the flat bunnyVideoId and bunnyVideoMeta fields. type and libraryId are computed on read (not stored). videoId is stored and indexed, so queries such as where: { 'bunnyData.stream.videoId': { equals } } keep working.

Migrate your data

v3.x ships a migration helper at @seshuk/payload-storage-bunny/migrations. It supports MongoDB, Postgres and SQLite and is idempotent — re-running it only touches documents that have not been migrated yet.
1

Upgrade the plugin to v3

2

Create a migration file

3

Call the helper from it

4

Run the migration

5

Remove the old fields

The legacy data lives in the bunnyVideoId and bunnyVideoMeta fields (MongoDB) — the bunny_video_id and bunny_video_meta columns on SQL. You do not declare these in your own config: the v2 plugin added them for you, and v3 no longer declares them, so after migrating they are leftover data with no field definition behind them.Once you have verified your app reads video metadata from bunnyData, delete the leftovers by passing drop: true. This unsets the fields (MongoDB) or drops the columns (Postgres/SQLite) for every managed collection:
You can run this as a one-off from any script with a Payload instance, or fold it into the migration once you’re confident:
drop is destructive and one-way — the legacy fields are gone afterward, so direction: 'rollback' can no longer copy data back. Only pass drop: true after you’ve verified the migrated data, or with a database backup in hand.

Database notes

MongoDB is schemaless, so there is no ordering constraint.If your project doesn’t use payload migrate, call migrateBunnyData({ payload }) once from any script that has a Payload instance.

Options

Need help?

Check the Examples page for working examples, or open an issue if you run into problems. For Payload upgrade help, see their official docs.