Migrating Bubble File Uploads: Preserve Attachments, Access and Deletion
A customer selects a document, the upload finishes, and they close the tab before saving the form. Another customer replaces an attachment while a migration is copying the previous version. A third deletes a file just before the new application goes live.
These moments deserve their own migration plan. A working download button proves little about what happens when uploads are interrupted, retried, replaced or removed.
Bubble's file and image fields contain URLs rather than the file bytes. Uploading a file and saving its URL are separate steps, so storage can contain files that were never attached to a completed record. Bubble's file documentation explains this distinction for its native file handling. If your app uses upload plugins or external storage, verify their behavior separately.
When migrating Bubble file uploads to custom code, preserve the relationship between the object, the attachment and the action that created or removed it. The Bubble data migration checklist covers the broader transfer. Here, the focus is what happens throughout each file's life.
Separate stored objects from saved attachments
Give the new application separate concepts for a stored object and an attachment. The object represents bytes in storage. The attachment connects that object to a business record, with a role such as invoice evidence, profile picture or project document.
This distinction answers questions that a single URL column cannot: Has the upload finished? Has the form been saved? Does another record still reference the same object? Was this attachment replaced, or explicitly deleted?
Choose stable identifiers for both concepts. Keep the original filename as display information, not as the object's identity. Two customers can upload different files called contract.pdf, and one customer can use that name repeatedly.
Record the source environment, storage provider and original locator as well as the destination object identifier. Treat matching content hashes as evidence of equal bytes, not proof that two attachments should share ownership or deletion behavior. Deduplication is a separate design decision.
Extend the manifest to capture lifecycle state
A transfer manifest records where files moved. A lifecycle manifest should also explain whether each attachment is supposed to exist now and what must happen next.
Use one attachment entry per relationship, linked to a separate object inventory when several attachments share bytes. The following field groups make a reusable starting point.
Identity and ownership
Record attachment_id, source_record_id, source_field, source_environment, source_locator, destination_record_id and destination_object_id. Include the owning account or tenant and the record that controls access. Keep sensitive locators in restricted operational storage rather than general application logs.
Upload and revision
Record upload_attempt_id, attachment_revision, predecessor_attachment_id and current_state. Useful states include receiving, uploaded, attached, superseded, deletion_requested and purged. Define exactly what each state means; an uploaded object is not automatically a saved attachment.
Evidence and recovery
Record expected_size, verified_size, checksum_algorithm, verified_checksum, verified_at, retry_count and last_error. Keep upload failure separate from attachment-save failure so a retry can recover the missing step instead of blindly repeating everything.
Removal and reconciliation
Record source_observed_at, last_reconciled_at, deletion_requested_at, retention_until, purge_status and purge_confirmed_at. Use an explicit unknown or pending value when evidence is missing. An empty deletion timestamp must not silently become permission to keep the object forever.
The manifest is operational state, not a spreadsheet that stops changing after the first copy.
Make interrupted uploads recoverable
Design the destination uploader around a durable attempt identifier. Create the attempt before transferring bytes, associate it with the intended owner, and distinguish transfer progress from a completed attachment save in the interface.
After upload, the server should confirm the expected object exists and passes the required checks before allowing the attachment to become active. When the user submits the form, save the attachment relationship using that attempt identifier. A lost response should be recoverable by asking whether the save already succeeded.
Define what happens when the user closes the tab, cancels the form or leaves an upload unfinished. A completed but unattached object can enter a temporary holding state. Cleanup should wait until the attempt has expired. Atomically claim that attempt for cleanup only if it has no completed attachment, and prevent a concurrent save from attaching an attempt already claimed. A separate no-reference check followed by deletion leaves a race in which a valid save can lose its file.
For large files, resumable transfer needs its own cleanup. With Amazon S3 multipart uploads, failed parts can be retried independently, but uploaded parts remain until the upload is completed or aborted. Track the upload session as well as the eventual object, and configure cleanup for abandoned sessions.
Rebuild the upload checks too. OWASP's file upload guidance recommends controls including permitted file types, generated storage names and size limits, and warns against trusting the supplied Content-Type alone. Decide how failed validation appears to the user without presenting the file as successfully attached.
Make retries and replacements different operations
A retry should finish the same logical operation. A replacement should create a new revision. Mixing them can produce duplicate attachments or allow an older request to overwrite a newer choice.
Use an idempotency key for attachment creation so repeated submissions return the existing result. Scope it to the authorized owner and operation. Before retrying after an uncertain response, inspect the recorded result and destination state.
For replacements, upload to a new object key, verify the new object, then change the active attachment reference in a database transaction. Keep the previous attachment active if the new upload fails. Mark the previous revision superseded only after the reference changes successfully.
Avoid using the original filename as a reusable destination key. In S3, a presigned upload to an existing key replaces the existing object. That behavior is documented in Amazon's presigned URL guide and is a reason to allocate keys deliberately. An issued upload URL can also be reused after validation while it remains valid. Finalize attachments against immutable bytes or a pinned, verified object version. One option is a server-controlled final object that the old upload URL cannot overwrite; confirm the storage configuration enforces that boundary.
Handle concurrent replacements explicitly. Require the attachment revision the user started from, and reject or reconcile a save when that revision is no longer current. Otherwise, a slow upload from one tab can undo a newer selection from another.
Decide what old links will do
An attachment's access policy must survive replacement and deletion as well as download. In Bubble, private uploads are attached to a database thing and depend on that thing's file-viewing privacy rules. Preserve that controlling relationship, rather than assuming every file belongs to the person who uploaded it. See the broader guide to migrating Bubble privacy rules.
Prefer a stable application download route that resolves an attachment identifier, checks current access and then serves the current permitted object. Decide whether a link identifies a specific immutable revision or the latest attachment. Those are different promises.
If the route issues signed storage URLs, account for their remaining lifetime after access changes. S3 presigned URLs are reusable bearer tokens until they expire or another applicable control prevents access. Signing out of the application does not, by itself, invalidate a URL already issued.
Inventory links in emails, exports and integrations. For addresses on domains you control, a compatibility route may preserve the intended behavior. A direct URL on a storage domain you do not control cannot simply be redirected by your new application. Choose whether those links remain temporarily available, are replaced in future communications, or stop working when source files are retired.
A fictional example: replacing a project document
Consider a fictional project portal called Cedar. Its production Bubble app has one active requirements document, revision A.
First, test the rebuilt uploader in a staging environment containing A. A tester uploads revision B but closes the form before saving. The destination upload attempt records B as uploaded but unattached, while A remains active. Returning within the recovery window can restore the unfinished form. After expiry, cleanup atomically claims the unattached attempt before removing B, so a concurrent save cannot attach a file already marked for cleanup. This tests the new uploader; it does not assume an unsaved Bubble upload automatically appears in the destination manifest.
Separately, consider production activity during migration. After the initial snapshot copies A, a customer successfully saves revision C in the still-live Bubble app. Final reconciliation detects that changed relationship, transfers and verifies C, then updates the destination reference using the observed revision. A becomes superseded under the agreed retention policy.
If the customer instead deletes the production attachment, reconciliation records a deletion rather than treating the empty field as missing export data. An earlier copy job for A must check that deletion state before activating its result. A late worker must not restore what the customer deliberately removed.
These tests distinguish an abandoned destination upload from a changed or deleted source attachment. Each needs its own evidence and outcome.
Reconcile attachment changes at the final boundary
The final attachment pass needs more than newly uploaded files. Include replacements, removals, changes to the controlling record and uploads still in progress.
Choose how to establish a trustworthy boundary: pause relevant attachment changes briefly, or capture changes durably and reconcile through an agreed checkpoint. Do not assume a record's generic modification timestamp captures every storage-side event.
Compare the final attachment relationships with the migration manifest. Every active relationship should resolve to its intended verified object. Every recorded removal should remain removed. Every unfinished attempt should have an owner and a defined recovery or expiry outcome.
Protect against stale workers with revision checks or deletion markers. A copy started earlier must not publish an outdated reference after a later replacement or deletion has won.
Keep exceptions visible by category: unavailable source, unauthorized source download, incomplete transfer, unattached destination object or unresolved relationship. A retryable access failure should never be converted into a successful empty attachment.
Finish with a deletion policy, not a cleanup guess
Before retiring source storage, agree which copies must remain, why, who owns that decision and when the decision is reviewed. Distinguish rollback copies, superseded revisions, abandoned uploads and files users explicitly removed.
Bubble documents that clearing a URL does not delete the underlying file. Its upload documentation describes a separate deletion action that requires the file URL. Preserve the locator until the relevant deletion has been confirmed.
In the new application, make deletion a tracked operation: remove normal access, record the request, check shared references and applicable retention requirements, then purge eligible objects. Retry failed purges without restoring access, and retain a minimal completion record.
Verify provider-specific behavior. In a versioned S3 bucket, an ordinary delete can add a delete marker while older versions remain. AWS's version deletion documentation distinguishes that from permanently removing a specific version. Include retained versions and derived previews in the deletion design, and document how backups age out.
Finally, compare the object inventory with active attachments and legitimate pending attempts. Treat unmatched objects as investigation candidates, not automatic deletion targets. An incomplete inventory can make a valid file look orphaned.
Include the file lifecycle in rebuild acceptance
Before source storage is switched off, ask the rebuild team to demonstrate these outcomes in a safe test environment:
- Retry a save after losing its response: exactly one attachment exists, with the same verified bytes.
- Fail a replacement upload: revision A remains active; a delayed save cannot overwrite a newer accepted revision.
- Finish an old copy after deletion: the deleted attachment stays removed.
- Race cleanup against saving an expired attempt: either the save wins and retains the file, or cleanup wins and the save is rejected safely.
- Open an old download link after access changes: it follows the agreed revision, expiry and access policy.
- Fail a purge and retry it: normal access stays removed, purge remains pending until confirmed, and required retained versions are accounted for.
Bubble to Code's rebuild process includes validation, cutover and handover. If attachments are important to your production app, book an introductory call to discuss their lifecycle alongside the rest of the rebuild.
Frequently asked questions
- Does clearing a Bubble file field delete the stored file?
- No. Clearing the URL and deleting the underlying file are separate operations. Preserve the source locator until the required deletion is confirmed, and make destination deletion a tracked operation with retention and shared-reference checks.
- How should interrupted uploads be handled after migration?
- Create a durable upload-attempt record before transferring bytes. Keep upload completion separate from attachment saving, allow safe recovery after uncertain responses, and clean up expired unattached objects without racing a concurrent save.
- Should a replacement upload overwrite the existing object?
- Prefer a new object and attachment revision. Verify the new bytes, switch the active reference transactionally, and mark the previous revision superseded only after the change succeeds.
Sources
- 01Files · Bubble Docs
- 02Uploading and deleting files · Bubble Docs
- 03Multipart upload overview · Amazon S3 User Guide
- 04Download and upload objects with presigned URLs · Amazon S3 User Guide
- 05Deleting object versions from a versioning-enabled bucket · Amazon S3 User Guide
- 06File Upload Cheat Sheet · OWASP Cheat Sheet Series
Keep reading
Bubble to Code is an independent service. Not affiliated with, endorsed by, or sponsored by Bubble Group, Inc.
