mirror of
https://github.com/marcogll/TaxHacker_s23.git
synced 2026-01-13 13:25:18 +00:00
feat: analyze all button, support for UTF8 filenames
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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() {
|
||||
<div className="flex flex-col gap-6 p-4 w-full max-w-6xl">
|
||||
<header className="flex items-center justify-between">
|
||||
<h2 className="text-3xl font-bold tracking-tight">You have {files.length} unsorted files</h2>
|
||||
{files.length > 1 && <AnalyzeAllButton />}
|
||||
</header>
|
||||
|
||||
{config.selfHosted.isEnabled && !settings.openai_api_key && (
|
||||
|
||||
Reference in New Issue
Block a user