Cannot upload PDF files: Provide Uint8Array rather than Buffer #28

Closed
opened 2026-02-15 19:15:18 -05:00 by yindo · 2 comments
Owner

Originally created by @SebastianVomMeer on GitHub (Jul 30, 2024).

After creating a new application with version 0.1.25 I cannot upload PDF files with the web interface.

The POST to http://localhost:3000/api/chat/upload responds with 500:

{"error":"Please provide binary data as `Uint8Array`, rather than `Buffer`."}

Related log:

Processing uploaded document of type: application/pdf
[Upload API] Error: Please provide binary data as `Uint8Array`, rather than `Buffer`.
    at /app/.next/server/chunks/602.js:9:144687
    at tH (/app/.next/server/chunks/602.js:9:145105)
    at i (/app/.next/server/chunks/804.js:1:153)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async l (/app/.next/server/chunks/804.js:1:780)
    at async u (/app/.next/server/chunks/804.js:1:1174)
    at async T (/app/.next/server/app/api/chat/upload/route.js:4:322)
    at async w.loadDataAsContent (/app/.next/server/app/api/chat/upload/route.js:4:146)
    at async S (/app/.next/server/app/api/chat/upload/route.js:4:976)
    at async R (/app/.next/server/app/api/chat/upload/route.js:5:793)
    at async L (/app/.next/server/app/api/chat/upload/route.js:5:1071)
    at async /app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:36258
    at async eR.execute (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:26874)
    at async eR.handle (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:37512)
    at async doRender (/app/node_modules/next/dist/server/base-server.js:1377:42)
    at async cacheEntry.responseCache.get.routeKind (/app/node_modules/next/dist/server/base-server.js:1599:28)

This fails when the application runs locally on my Ubuntu 20.04 machine as well as inside a docker container with image nextjs-docker (started as described in your generated README.md). It happens in Chrome and Firefox.

I use azure-openai as model provider but I don't think that this is related. Indexing PDFs with npm run generate works just fine.


✔ What is your project named? … my-app
✔ Which template would you like to use? › Agentic RAG (single agent)
✔ Which framework would you like to use? › NextJS
✔ Would you like to set up observability? › No
✔ Please provide your OpenAI API key (leave blank to skip): … 
✔ Which data source would you like to use? › Use an example PDF (you can add your own data files later)
✔ Would you like to add another data source? › No
✔ Would you like to use LlamaParse (improved parser for RAG - requires API key)? … no / yes › No
✔ Would you like to use a vector database? › No, just store the data in the file system
✔ Would you like to build an agent using tools? If so, select the tools here, otherwise just press enter › 
✔ How would you like to proceed? › Generate code and install dependencies (~2 min)
Originally created by @SebastianVomMeer on GitHub (Jul 30, 2024). After creating a new application with version 0.1.25 I cannot upload PDF files with the web interface. The POST to http://localhost:3000/api/chat/upload responds with 500: {"error":"Please provide binary data as `Uint8Array`, rather than `Buffer`."} Related log: ``` Processing uploaded document of type: application/pdf [Upload API] Error: Please provide binary data as `Uint8Array`, rather than `Buffer`. at /app/.next/server/chunks/602.js:9:144687 at tH (/app/.next/server/chunks/602.js:9:145105) at i (/app/.next/server/chunks/804.js:1:153) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async l (/app/.next/server/chunks/804.js:1:780) at async u (/app/.next/server/chunks/804.js:1:1174) at async T (/app/.next/server/app/api/chat/upload/route.js:4:322) at async w.loadDataAsContent (/app/.next/server/app/api/chat/upload/route.js:4:146) at async S (/app/.next/server/app/api/chat/upload/route.js:4:976) at async R (/app/.next/server/app/api/chat/upload/route.js:5:793) at async L (/app/.next/server/app/api/chat/upload/route.js:5:1071) at async /app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:36258 at async eR.execute (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:26874) at async eR.handle (/app/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:6:37512) at async doRender (/app/node_modules/next/dist/server/base-server.js:1377:42) at async cacheEntry.responseCache.get.routeKind (/app/node_modules/next/dist/server/base-server.js:1599:28) ``` This fails when the application runs locally on my Ubuntu 20.04 machine as well as inside a docker container with image nextjs-docker (started as described in your generated README.md). It happens in Chrome and Firefox. I use azure-openai as model provider but I don't think that this is related. Indexing PDFs with `npm run generate` works just fine. --- ``` ✔ What is your project named? … my-app ✔ Which template would you like to use? › Agentic RAG (single agent) ✔ Which framework would you like to use? › NextJS ✔ Would you like to set up observability? › No ✔ Please provide your OpenAI API key (leave blank to skip): … ✔ Which data source would you like to use? › Use an example PDF (you can add your own data files later) ✔ Would you like to add another data source? › No ✔ Would you like to use LlamaParse (improved parser for RAG - requires API key)? … no / yes › No ✔ Would you like to use a vector database? › No, just store the data in the file system ✔ Would you like to build an agent using tools? If so, select the tools here, otherwise just press enter › ✔ How would you like to proceed? › Generate code and install dependencies (~2 min) ```
yindo closed this issue 2026-02-15 19:15:18 -05:00
Author
Owner

@SebastianVomMeer commented on GitHub (Jul 30, 2024):

Converting the fileBuffer in app/api/chat/llamaindex/documents/helper.ts seems to be a workaround for me, but I don't have a clue about this topic.

  console.log(`Processing uploaded document of type: ${mimeType}`);
  return await reader.loadDataAsContent(new Uint8Array(fileBuffer));
@SebastianVomMeer commented on GitHub (Jul 30, 2024): Converting the fileBuffer in app/api/chat/llamaindex/documents/helper.ts seems to be a workaround for me, but I don't have a clue about this topic. ``` console.log(`Processing uploaded document of type: ${mimeType}`); return await reader.loadDataAsContent(new Uint8Array(fileBuffer)); ```
Author
Owner

@marcusschiesser commented on GitHub (Jul 31, 2024):

Thanks. Fixed in Release 0.1.26

@marcusschiesser commented on GitHub (Jul 31, 2024): Thanks. Fixed in Release 0.1.26
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: run-llama/create-llama#28