diff --git a/app/(app)/files/download/[fileId]/route.ts b/app/(app)/files/download/[fileId]/route.ts index a7a2682..6e9198d 100644 --- a/app/(app)/files/download/[fileId]/route.ts +++ b/app/(app)/files/download/[fileId]/route.ts @@ -1,5 +1,6 @@ import { getCurrentUser } from "@/lib/auth" import { fileExists, fullPathForFile } from "@/lib/files" +import { encodeFilename } from "@/lib/utils" import { getFileById } from "@/models/files" import fs from "fs/promises" import { NextResponse } from "next/server" @@ -30,12 +31,12 @@ export async function GET(request: Request, { params }: { params: Promise<{ file // Read file const fileBuffer = await fs.readFile(fullFilePath) - // Return file with proper content type + // Return file with proper content type and encoded filename return new NextResponse(fileBuffer, { headers: { "Content-Type": file.mimetype, - "Content-Disposition": `attachment; filename="${file.filename}"`, - }, + "Content-Disposition": `attachment; filename*=${encodeFilename(file.filename)}`, + }, }) } catch (error) { console.error("Error serving file:", error) diff --git a/app/(app)/files/preview/[fileId]/route.ts b/app/(app)/files/preview/[fileId]/route.ts index 7ee7ca5..8483c85 100644 --- a/app/(app)/files/preview/[fileId]/route.ts +++ b/app/(app)/files/preview/[fileId]/route.ts @@ -5,6 +5,7 @@ import { getFileById } from "@/models/files" import fs from "fs/promises" import { NextResponse } from "next/server" import path from "path" +import { encodeFilename } from "@/lib/utils" export async function GET(request: Request, { params }: { params: Promise<{ fileId: string }> }) { const { fileId } = await params @@ -46,7 +47,7 @@ export async function GET(request: Request, { params }: { params: Promise<{ file return new NextResponse(fileBuffer, { headers: { "Content-Type": contentType, - "Content-Disposition": `inline; filename="${path.basename(previewPath)}"`, + "Content-Disposition": `inline; filename*=${encodeFilename(path.basename(previewPath))}`, }, }) } catch (error) { diff --git a/app/(app)/unsorted/page.tsx b/app/(app)/unsorted/page.tsx index 8911bdc..3179939 100644 --- a/app/(app)/unsorted/page.tsx +++ b/app/(app)/unsorted/page.tsx @@ -3,6 +3,7 @@ import { UploadButton } from "@/components/files/upload-button" import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert" import { Button } from "@/components/ui/button" import { Card } from "@/components/ui/card" +import { AnalyzeAllButton } from "@/components/unsorted/analyze-all-button" import AnalyzeForm from "@/components/unsorted/analyze-form" import { getCurrentUser } from "@/lib/auth" import config from "@/lib/config" @@ -12,7 +13,7 @@ import { getFields } from "@/models/fields" import { getUnsortedFiles } from "@/models/files" import { getProjects } from "@/models/projects" import { getSettings } from "@/models/settings" -import { FileText, PartyPopper, Settings, Upload } from "lucide-react" +import { FileText, PartyPopper, Settings, Upload, Brain } from "lucide-react" import { Metadata } from "next" import Link from "next/link" @@ -34,6 +35,7 @@ export default async function UnsortedPage() {

You have {files.length} unsorted files

+ {files.length > 1 && }
{config.selfHosted.isEnabled && !settings.openai_api_key && ( diff --git a/components/unsorted/analyze-all-button.tsx b/components/unsorted/analyze-all-button.tsx new file mode 100644 index 0000000..25e803d --- /dev/null +++ b/components/unsorted/analyze-all-button.tsx @@ -0,0 +1,19 @@ +"use client" + +import { Button } from "@/components/ui/button" +import { Swords } from "lucide-react" + +export function AnalyzeAllButton() { + const handleAnalyzeAll = () => { + document.querySelectorAll("button[data-analyze-button]").forEach((button) => { + ;(button as HTMLButtonElement).click() + }) + } + + return ( + + ) +} diff --git a/components/unsorted/analyze-form.tsx b/components/unsorted/analyze-form.tsx index 9547208..e14fc4d 100644 --- a/components/unsorted/analyze-form.tsx +++ b/components/unsorted/analyze-form.tsx @@ -141,7 +141,7 @@ export default function AnalyzeForm({ return ( <> -