Create upload status check endpoint

This commit is contained in:
regalijan 2023-10-19 16:49:24 -04:00
parent 95d0686eaa
commit eb1a246da8
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -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
@ -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,
});
}