Skip to content

storage-vercel-blob: clientUploads stores WebP, GIF and cropped uploads as 0-byte objects #18333

Closed
NWACus/web
#1475

Description

@franknoel

Describe the Bug

With clientUploads: true on @payloadcms/storage-vercel-blob, any client upload that Payload runs through sharp ends up stored as a 0-byte object, while the document keeps a non-zero filesize. That covers every WebP, GIF and TIFF (isAnimatedImage types), any image cropped in the same save as its client upload, and every resizable image when the collection sets resizeOptions, formatOptions, trimOptions or constructorOptions.

The mechanism on 3.90.2:

  1. getFileFromClientUpload returns the file with data: Buffer.alloc(0) and a tempFilePath (since fix: avoid buffering large client uploads into memory #17856 / fix: avoid buffering large client uploads into memory #17872, 3.89.0).
  2. generateFileData runs sharp for these files, then delete file.clientUploadContext (and fileForResize.clientUploadContext in the crop path). Because a tempFilePath exists, it writes the processed bytes only to that temp file (fs.writeFile(file.tempFilePath, …)) and leaves req.file.data empty.
  3. plugin-cloud-storage's afterChange no longer sees a clientUploadContext, so it stops skipping the file and calls adapter.handleUpload with buffer: file.data, the empty buffer.
  4. The Vercel Blob adapter puts that buffer with allowOverwrite: true at <prefix>/<_objectKey>/<filename>, replacing the file the browser had just uploaded with 0 bytes.

The deletes were added in 3.90.0 by 8e880a4 ("fix: incorrect prefix from client upload"). The same deletes are on 3.x and on main (as uploadReference). JPEG, PNG and AVIF without edits are not affected unless the collection sets one of the options above: otherwise sharp does not run, clientUploadContext survives and afterChange skips them.

The GCS, R2 and UploadThing adapters also upload only file.buffer, so they should be affected the same way; S3 and Azure read tempFilePath when present. We only reproduced it on Vercel Blob.

A possible fix: have getIncomingFiles (or each adapter) read tempFilePath when present, as the S3 and Azure adapters do, or keep clientUploadContext and re-upload the processed file explicitly.

Link to the code that reproduces this issue

https://github.com/franknoel/payload-blob-client-upload-empty (blank template plus storage-vercel-blob with clientUploads: true; pnpm check compares each document's filesize with its stored object)

Reproduction Steps

  1. Configure storage-vercel-blob with clientUploads: true on an upload collection, with sharp set in the Payload config:
    vercelBlobStorage({
      clientUploads: true,
      collections: { media: true },
      token: process.env.BLOB_READ_WRITE_TOKEN,
    })
  2. In the admin, upload a WebP (or a PNG with a crop set before saving). Save.
  3. The document shows the expected filesize, width and height, but head() or list() on the Blob store shows the object at 0 bytes, and the image URL returns an empty body.

We hit this on a staging site: WebP images editors uploaded after moving to 3.90 were stored as 0-byte objects. We reproduced the crop case locally.

Which area(s) are affected?

plugin: cloud-storage, plugin: storage-*, area: core

Environment Info

payload: 3.90.2
@payloadcms/plugin-cloud-storage: 3.90.2
@payloadcms/storage-vercel-blob: 3.90.2
next: 16.3.6
sharp: 0.35.4
Node: 24.21.0, deployed on Vercel

Activity

  1. added
    area: core
    plugin: cloud-storage
    on Sep 26, 2026
  2. self-assigned this
    on Sep 28, 2026
  3. razaanstha commented on Sep 29, 2026

    @razaanstha

    +1

  4. drianoaz commented on Oct 17, 2026

    @drianoaz

    Reproduced on 3.91.0 as well (payload, @payloadcms/plugin-cloud-storage and @payloadcms/storage-vercel-blob 3.91.0, next start, real Vercel Blob store), so the latest stable is still affected.

    One difference worth noting for anyone using addRandomSuffix: true: the browser's object is not overwritten. handleUpload puts the empty buffer under a new suffixed key, and afterChange rewrites the document's filename to it:

    Object Size (bytes)
    <_objectKey>/photo.webp (client upload, now orphaned) 198070
    <_objectKey>/photo-<suffix>.webp (server re-upload, what the document points to) 0

    So with a suffix the original bytes survive, and affected documents can be recovered by re-uploading or re-pointing them. Without a suffix they are overwritten, as described above.

    To find affected documents, list the store and look for 0-byte objects that have a non-empty sibling with the same base name in the same _objectKey folder.

    Symptom in the admin, in case it helps others find this issue: the thumbnail is broken and the crop dialog shows width and height as 0.

    @nathanlentz, does #18387 / #18388 also cover addRandomSuffix: true? From the description, processed client uploads keep the receipt's key, which would also stop the suffixed duplicate.

  5. nathanlentz commented on Oct 21, 2026

    @nathanlentz
    Collaborator

    @drianoaz I'll address the addRandomSuffix: true issue you describe in a separate pull request.

  6. added 4 commits that reference this issue on Oct 23, 2026
    210de57
    6fc83d7
    f2cbc85
    ea3778b
  7. github-actions commented on Oct 27, 2026

    @github-actions
    Contributor

    🚀 This is included in version v3.92.1

  8. nathanlentz commented on Oct 29, 2026

    @nathanlentz
    Collaborator

    This issue is resolved via #19010 and #19012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Bugarea: coreplugin: cloud-storageplugin: storage-*

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions