From be622e5594ecb21c82bb6066a82c86e0917bcc35 Mon Sep 17 00:00:00 2001 From: Ahmad Mujahid <55625580+AhmadMuj@users.noreply.github.com> Date: Thu, 11 Apr 2024 15:29:51 +0400 Subject: feature: Add PDF support (#88) * feature: Add PDF support * fix: PDF feature enhancements * fix: Freeze expo-share-intent version to prevent breaking changes * fix: set endOfLine to auto for cross-platform development * fix: Upgrading eslint/parser and eslint-plugin to 7.6.0 to solve the linting issues * fix: enhancing PDF feature * fix: Allowing null in fiename for backward compatibility * fix: update pnpm file with pnpm 9.0.0-alpha-8 * fix:(web): PDF Preview for web --- apps/web/app/api/assets/route.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'apps/web/app') diff --git a/apps/web/app/api/assets/route.ts b/apps/web/app/api/assets/route.ts index 0bb2f778..5b72033a 100644 --- a/apps/web/app/api/assets/route.ts +++ b/apps/web/app/api/assets/route.ts @@ -9,6 +9,7 @@ const SUPPORTED_ASSET_TYPES = new Set([ "image/jpeg", "image/png", "image/webp", + "application/pdf", ]); const MAX_UPLOAD_SIZE_BYTES = serverConfig.maxAssetSizeMb * 1024 * 1024; @@ -26,7 +27,7 @@ export async function POST(request: Request) { }); } const formData = await request.formData(); - const data = formData.get("image"); + const data = formData.get("file") ?? formData.get("image"); let buffer; let contentType; if (data instanceof File) { @@ -46,11 +47,12 @@ export async function POST(request: Request) { } const assetId = crypto.randomUUID(); + const fileName = data.name; await saveAsset({ userId: ctx.user.id, assetId, - metadata: { contentType }, + metadata: { contentType, fileName }, asset: buffer, }); @@ -58,5 +60,6 @@ export async function POST(request: Request) { assetId, contentType, size: buffer.byteLength, + fileName, } satisfies ZUploadResponse); } -- cgit v1.2.3-70-g09d2