Fix file uploading for infractions
This commit is contained in:
@ -77,6 +77,12 @@ export async function onRequestPost(context: RequestContext) {
|
||||
// @ts-expect-error
|
||||
const files: File[] = body.keys().find((key) => key.match(/^files\[\d]$/));
|
||||
const urlPromises = [];
|
||||
const origin = context.request.headers.get("Origin");
|
||||
|
||||
if (!origin)
|
||||
return new Response('{"error":"Origin header missing"}', {
|
||||
status: 400,
|
||||
});
|
||||
|
||||
for (const file of files) {
|
||||
if (!allowedFileTypes.includes(file.type))
|
||||
@ -97,6 +103,7 @@ export async function onRequestPost(context: RequestContext) {
|
||||
attachmentKey,
|
||||
file.size,
|
||||
(allowedFileTypes.find((t) => t === file.type) as string).split("/")[1],
|
||||
origin,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user