Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Slightly unbreak file processing
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 7f39f0d commit 788e14e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions functions/api/reports/submit.ts
Expand Up @@ -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 ||
Expand Down Expand Up @@ -211,15 +210,15 @@ export async function onRequestPost(context: RequestContext) {
for (const urlResult of uploadUrlResults as PromiseFulfilledResult<string>[]) {
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);
Expand Down

0 comments on commit 788e14e

Please sign in to comment.