fix(storage-*): client uploads with disablePayloadAccessControl: true (#11530)

Fixes https://github.com/payloadcms/payload/issues/11473

Previously, when `disablePayloadAccessControl: true` was defined, client
uploads were working improperly. The reason is that
`addDataAndFileToRequest` expects `staticHandler` to be defined and we
don't add in case if `disablePayloadAccessControl: true`.

This PR makes it so otherwise and if we have `clientUploads`, it pushes
the "proxied" handler that responses only when the file was requested in
the context of client upload (from `addDataAndFileToRequest`)
This commit is contained in:
Sasha
2025-03-05 20:59:49 +02:00
committed by GitHub
parent 6939a835ca
commit 5cc0e74471
7 changed files with 28 additions and 4 deletions

View File

@@ -172,7 +172,7 @@ function vercelBlobStorageInternal(
options: { baseUrl: string } & VercelBlobStorageOptions,
): Adapter {
return ({ collection, prefix }): GeneratedAdapter => {
const { access, addRandomSuffix, baseUrl, cacheControlMaxAge, token } = options
const { access, addRandomSuffix, baseUrl, cacheControlMaxAge, clientUploads, token } = options
if (!token) {
throw new Error('Vercel Blob storage token is required')
@@ -180,6 +180,7 @@ function vercelBlobStorageInternal(
return {
name: 'vercel-blob',
clientUploads,
generateURL: getGenerateUrl({ baseUrl, prefix }),
handleDelete: getHandleDelete({ baseUrl, prefix, token }),
handleUpload: getHandleUpload({