Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simplify url generation
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 28ea352 commit 25a8623
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions functions/api/reports/submit.ts
Expand Up @@ -182,7 +182,7 @@ export async function onRequestPost(context: RequestContext) {
);
}

const uploadUrls = await Promise.allSettled(uploadUrlPromises);
const uploadUrlResults = await Promise.allSettled(uploadUrlPromises);

const reportId = `${Date.now()}${context.request.headers.get(
"cf-ray",
Expand All @@ -196,12 +196,15 @@ export async function onRequestPost(context: RequestContext) {
{ expirationTtl: 3600 },
);

if (uploadUrls.find((uploadUrl) => uploadUrl.status === "rejected"))
if (uploadUrlResults.find((uploadUrl) => uploadUrl.status === "rejected"))
return errorResponse("Failed to generate upload url", 500);

const attachments: string[] = [];
const uploadUrls: string[] = [];

for (const urlResult of uploadUrlResults as PromiseFulfilledResult<string>[]) {
uploadUrls.push(urlResult.value);

for (const urlResult of uploadUrls) {
let url = urlResult.toString().replace("t/", "");
const extension = (url.split(".").at(-1) as string).toLowerCase();

Expand Down

0 comments on commit 25a8623

Please sign in to comment.