1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-05 13:15:18 +02:00

Merge pull request #89 from seanmorley15/development

chore: Add authorization check in upload server endpoint
This commit is contained in:
Sean Morley 2024-06-13 10:11:53 -04:00 committed by GitHub
commit 67222fd83d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,6 +14,15 @@ import { generateId } from "lucia";
*/
export async function POST(event: RequestEvent): Promise<Response> {
try {
if (!event.locals.user) {
return new Response(JSON.stringify({ error: "Unauthorized" }), {
status: 401,
headers: {
"Content-Type": "application/json",
},
});
}
const contentType = event.request.headers.get("content-type") ?? "";
const fileExtension = contentType.split("/").pop();
const fileName = `${generateId(75)}.${fileExtension}`;