Skip to content

Commit a5ee2f9

Browse files
drahoja9zoul
authored andcommitted
feat: limit file upload to PNG/JPEG/PDF
1 parent 6adfb78 commit a5ee2f9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

app/upload/UploadForm.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export const UploadForm = () => {
6767
const ErrorView = () => (
6868
<p className="max-w-prose">
6969
⚠️ Soubor se nepovedlo nahrát. Jsi přihlášený nebo přihlášená? Máš oprávnění
70-
nahrávat soubory? Samé otázky. V případě potřeby se{" "}
70+
nahrávat soubory? Nahráváš správné typy souborů (PNG, JPEG či PDF)? Samé
71+
otázky. V případě potřeby se{" "}
7172
<a
7273
className="typo-link"
7374
href="https://cesko-digital.slack.com/archives/CHG9NA23D"

app/upload/upload/route.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ export async function POST(request: Request): Promise<Response> {
2525
const jsonResponse = await handleUpload({
2626
body,
2727
request,
28-
onBeforeGenerateToken: async () => ({ addRandomSuffix: false }),
28+
onBeforeGenerateToken: async () => ({
29+
addRandomSuffix: false,
30+
allowedContentTypes: ["image/png", "image/jpeg", "application/pdf"],
31+
}),
2932
onUploadCompleted: async () => {},
3033
});
3134
return NextResponse.json(jsonResponse);

0 commit comments

Comments
 (0)