Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Create upload status check endpoint
  • Loading branch information
regalijan committed Oct 19, 2023
1 parent 95d0686 commit eb1a246
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions functions/api/uploads/[[id]].ts
@@ -1,14 +1,4 @@
export async function onRequestGet(context: RequestContext) {
const { current_user: currentUser } = context.data;

if (!(currentUser?.permissions & (1 << 5)))
return new Response('{"error":"Forbidden"}', {
headers: {
"content-type": "application/json",
},
status: 403,
});

const attachment = context.params.id as string;
const unsignedURL = `https://mediaproxy.carcrushers.cc/${attachment}?Expires=${(
Math.round(Date.now() / 1000) + 1800
Expand All @@ -33,3 +23,13 @@ export async function onRequestGet(context: RequestContext) {
.replaceAll("=", "")}`
);
}

export async function onRequestHead(context: RequestContext) {
const attachment = context.params.id as string;

return new Response(null, {
status: (await context.env.DATA.get(`videoprocessing_${attachment}`))
? 409
: 204,
});
}

0 comments on commit eb1a246

Please sign in to comment.