From 6b1b44502ae35a28379fbe1ecd788253904db780 Mon Sep 17 00:00:00 2001 From: kovakmedya Date: Thu, 21 May 2026 21:08:26 +0300 Subject: [PATCH] fix(upload): convert File to Buffer via InputFile.fromBuffer before sending to storage.createFile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit node-appwrite's storage.createFile happily takes the Web File API today, but Next.js's multipart parser had already consumed the request body by the time the SDK tries to stream it again — the SDK's second pass dies with 'Unexpected end of form'. isletmem-kovakcrm's logo-actions uses the documented pattern: arrayBuffer → Buffer → InputFile.fromBuffer(buf, name). Adopting the same approach in uploadJobFilesAction. The middlewareClientMaxBodySize bump from the previous commit still matters (lifts the 10MB cap so the body even reaches us), but on its own it wasn't enough: the Web File handoff itself was broken. InputFile is exported from 'node-appwrite/file' (separate entry point — the helper isn't on the main package export). --- src/lib/appwrite/job-file-actions.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/appwrite/job-file-actions.ts b/src/lib/appwrite/job-file-actions.ts index 5071520..9a1e7a0 100644 --- a/src/lib/appwrite/job-file-actions.ts +++ b/src/lib/appwrite/job-file-actions.ts @@ -2,6 +2,7 @@ import { revalidatePath } from "next/cache"; import { AppwriteException, ID, Permission, Role } from "node-appwrite"; +import { InputFile } from "node-appwrite/file"; import { logAudit } from "./audit"; import { @@ -99,10 +100,12 @@ export async function uploadJobFilesAction( try { for (const f of files) { const fileId = ID.unique(); + const buffer = Buffer.from(await f.arrayBuffer()); + const inputFile = InputFile.fromBuffer(buffer, f.name); await storage.createFile({ bucketId: BUCKETS.jobFiles, fileId, - file: f, + file: inputFile, permissions: filePermissions(job.clinicTenantId, job.labTenantId), }); uploadedFileIds.push(fileId);