Skip to content

fix: File upload example (BLO-1311) - #2996

Open
matthewlipski wants to merge 2 commits into
mainfrom
fix-file-upload
Open

fix: File upload example (BLO-1311)#2996
matthewlipski wants to merge 2 commits into
mainfrom
fix-file-upload

Conversation

@matthewlipski

@matthewlipski matthewlipski commented Aug 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR fixes the file upload example and related file upload code as tmpfiles changed their API and it no longer works for our use. To prevent issues like that happening in the future, we now just save the file as a base64 URL.

Closes @2967

Rationale

The example is broken.

Changes

  • Updated docs demo.
  • Updated file upload example.
  • Updated Uppy file panel example.
  • Updated and renamed uploadFilesToTmpFilesDotOrg_DEV_ONLY to uploadFile_DEV_ONLY.

Impact

N/A

Testing

N/A - TODO?

Screenshots/Video

N/A

Checklist

  • Code follows the project's coding standards.
  • Unit tests covering the new feature have been added.
  • All existing tests pass.
  • The documentation has been updated to reflect the new feature

Additional Notes

N/A

Summary by CodeRabbit

  • New Features

    • Development file uploads now produce local base64 data URLs instead of relying on an external temporary-file service.
    • Uppy image uploads support processing multiple completed files using the generated data URLs.
  • Documentation

    • Updated file-upload guidance and examples to use local development uploads.
    • Clarified that production applications should provide their own backend upload implementation.
  • Bug Fixes

    • Updated image upload checks to recognize data URL sources.

@vercel

vercel Bot commented Aug 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blocknote Ready Ready Preview Aug 21, 2026 1:06pm
blocknote-website Ready Ready Preview Aug 21, 2026 1:06pm

Request Review

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 43ab0f64-0720-4cf0-9b1e-3507ffa78783

📥 Commits

Reviewing files that changed from the base of the PR and between d7c2890 and 9ccd1f8.

📒 Files selected for processing (3)
  • examples/01-basic/testing/src/App.tsx
  • packages/core/src/blocks/File/helpers/uploadFile_DEV_ONLY.ts
  • tests/src/unit/core/createTestEditor.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Changes

The PR replaces tmpfiles.org uploads with BlockNote’s development-only helper. The helper returns base64 data URLs. Examples, documentation, the Uppy panel, exports, and tests now use the local upload flow.

Local data URL uploads

Layer / File(s) Summary
Development-only upload helper and examples
packages/core/src/blocks/File/helpers/uploadFile_DEV_ONLY.ts, packages/core/src/blocks/index.ts, docs/app/demo/..., examples/01-basic/testing/src/App.tsx, examples/02-backend/01-file-uploading/..., docs/content/docs/react/components/image-toolbar.mdx, playground/src/examples.gen.tsx
uploadFile_DEV_ONLY reads files as data URLs. The export, examples, and documentation use the helper and describe backend replacement for production.
Uppy completion flow
examples/03-ui-components/11-uppy-file-panel/src/UppyFilePanel.tsx
The Uppy panel removes its XHR uploader, processes completed files with uploadFile_DEV_ONLY, updates blocks with data URLs, and simplifies its exported upload function.
Test upload wiring
tests/src/unit/core/createTestEditor.ts, tests/src/end-to-end/images/images.test.tsx
Test editors use uploadFile_DEV_ONLY, and the image test detects data URL sources.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 9ccd1

This PR updates file-upload examples and helper usage to use base64 URLs; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant Uppy
  participant uploadFile_DEV_ONLY
  participant BlockNoteEditor
  Uppy->>uploadFile_DEV_ONLY: Process each successful file
  uploadFile_DEV_ONLY-->>Uppy: Return base64 data URL
  Uppy->>BlockNoteEditor: Update block with file name and data URL
Loading

Suggested reviewers: nperez0111

Poem

A rabbit reads each file with care,
A data URL forms in air.
Uppy sends no bytes afar,
Each image stays just where they are.
Local blocks now hold the prize.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: fixing the file upload example.
Description check ✅ Passed The description covers all required sections and accurately summarizes the base64 upload changes, but testing details and checklist items remain incomplete.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-file-upload

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nperez0111 nperez0111 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change it from being exported? Otherwise fine to move off the actual upload path

@@ -1,3 +1,5 @@
import { uploadFile_DEV_ONLY } from "@blocknote/core";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't really want this exported, I get that it is a shared util, but not one that needs to be actually packaged. Just copy-paste in the places that need it

export * from "./Code/helpers/toExternalHTML/createPreCode.js";
export * from "./ToggleWrapper/createToggleWrapper.js";
export * from "./File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.js";
export * from "./File/helpers/uploadFile_DEV_ONLY.js";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh we had this exported before? That is strange to me

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I still remove the export then? Or keep as it was?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd remove it

@pkg-pr-new

pkg-pr-new Bot commented Aug 21, 2026

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@2996

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@2996

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@2996

@blocknote/diagram-block

npm i https://pkg.pr.new/@blocknote/diagram-block@2996

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@2996

@blocknote/math-block

npm i https://pkg.pr.new/@blocknote/math-block@2996

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@2996

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@2996

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@2996

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@2996

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@2996

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@2996

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@2996

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@2996

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@2996

commit: 9ccd1f8

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://TypeCellOS.github.io/BlockNote/pr-preview/pr-2996/

Built to branch gh-pages at 2026-08-21 13:12 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants