Repository navigation
feat!: add upload file versioning - #18548
Conversation
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
ddaa0af to
b4ec8d9
Compare
b4ec8d9 to
9d32910
Compare
521fbdb to
5746cb4
Compare
| } | ||
|
|
||
| // Server-owned key segment; hidden from the API and admin, read internally via showHiddenFields. | ||
| // Server-owned key segment. Field-level `hidden` would remove it before the URL hooks can read it. |
There was a problem hiding this comment.
Keep object keys available during selected reads
Positive selections can remove prefix and _objectKey before the URL hook runs. Admin list and relationship requests select filename and URL fields, so the hook regenerates direct URLs without the UUID folder and returns 404. Keep these internal fields available to URL hooks regardless of selection, and add tests for selected top-level, original, and variant URLs.
There was a problem hiding this comment.
0adbb5b. Fixed there for top-level and original URLs. Variant URLs look like they are affected by a transformer-order bug (for third party adapters) which I think should be handled in a fast follow/smaller PR.
| const isDuplicatingAnOriginal = | ||
| isDuplicating && file.name === (originalDoc as FileData | undefined)?.original?.filename | ||
|
|
||
| if (!fileWasTransformed && !retainedOriginal && !providerOriginal && !isDuplicatingAnOriginal) { |
There was a problem hiding this comment.
Preserve provider filenames for references without receipts
A provider reference without a signed receipt reaches this branch and renames photo.png to photo-original.png. The cloud hook skips files with uploadReference, so the saved document points to a file that was never uploaded. Preserve the provider filename or copy the object, and test the documented uploadReference: {} flow.
There was a problem hiding this comment.
0adbb5b. Fixed with tests for both a text file and a png.
| relative: true, | ||
| }) | ||
| } | ||
| if (doc.url !== (await expectedURL({ filename: doc.filename }))) { |
There was a problem hiding this comment.
Recognise legacy files with changing URLs
hasLegacyFile regenerates the provider URL and requires exact equality with the stored URL. Signed or time-limited URLs change, so Payload does not migrate the object and later historical versions cannot resolve it. Identify legacy files from stable storage data, and test replacement after the URL signature changes.
There was a problem hiding this comment.
0adbb5b. Fixed with a test that covers main and variant URLs
…nd signed legacy URLs
…ces, and signed legacy URLs
# Conflicts: # packages/payload/src/collections/operations/restoreVersion.ts # packages/payload/src/collections/operations/utilities/update.ts # packages/payload/src/index.ts
|
🚀 This is included in version v4.0.0-canary.39 |
Written by AI
What?
This is part 2 of the two-PR file versioning stack. It adds the Payload and storage adapter implementation for the behavior defined in #18547.
Versioned upload documents now retain their original source and every stored representation needed by current or historical versions. Restore, pruning, replacement, rename, and deletion preserve referenced objects and remove objects after their final reference is removed.
Why?
Payload document versions previously retained upload metadata without managing the corresponding stored files. Historical versions could therefore reference replaced or deleted objects.
How?
original, and each configured variant.GeneratedAdapter.copyFileoperation.-originalfilename. Code and infrastructure that depend on the previous filename, URL, or object key must account for the new location.original,prefix, and_objectKeyfields. Relational database projects must generate and apply the corresponding schema migration.API
Applications can rename an upload and its stored representations through
payload.renameFile, the REST rename endpoint, or the generated GraphQL mutation. Existing upload create, update, delete, draft, and restore operations manage file history automatically.