From 788e14e971174750b36b8030fd728f3bd1f98219 Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:50:38 -0400 Subject: [PATCH] Slightly unbreak file processing --- functions/api/reports/submit.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/functions/api/reports/submit.ts b/functions/api/reports/submit.ts index abb5c3d..88194c7 100644 --- a/functions/api/reports/submit.ts +++ b/functions/api/reports/submit.ts @@ -145,8 +145,7 @@ export async function onRequestPost(context: RequestContext) { const fileParts = file.name.split("."); let fileExten = fileParts.at(-1); - if (fileExten.toLowerCase() === "mov") - fileExten = "mp4" + if (fileExten.toLowerCase() === "mov") fileExten = "mp4"; if ( fileParts.length < 2 || @@ -211,15 +210,15 @@ export async function onRequestPost(context: RequestContext) { for (const urlResult of uploadUrlResults as PromiseFulfilledResult[]) { uploadUrls.push(urlResult.value); - let url = urlResult.value.replace("t/", ""); + let url = new URL(urlResult.value).searchParams.get("name") as string; const extension = (url.split(".").at(-1) as string).toLowerCase(); if (["mkv", "wmv"].includes(extension)) { - await context.env.DATA.put(`videoprocessing_${url.replace(`.${extension}`, ".mp4")}`, "1", { + url = url.replace(`.${extension}`, ".mp4"); + + await context.env.DATA.put(`videoprocessing_${url}`, "1", { expirationTtl: 600, }); - - url = url.replace(`.${extension}`, ".mp4"); } attachments.push(url);