Start work on moving transcoding jobs to coconut
This commit is contained in:
parent
523b348978
commit
c770e673fb
@ -1,5 +1,5 @@
|
||||
import { GenerateUploadURL } from "../../gcloud.js";
|
||||
import { jsonError, jsonResponse } from "../../common.js";
|
||||
import upload from "../upload.js";
|
||||
|
||||
export async function onRequestPost(context: RequestContext) {
|
||||
const {
|
||||
@ -137,6 +137,7 @@ export async function onRequestPost(context: RequestContext) {
|
||||
}
|
||||
|
||||
const uploadUrlPromises: Promise<string>[] = [];
|
||||
const filesToProcess = [];
|
||||
|
||||
for (const file of files) {
|
||||
const fileParts = file.name.split(".");
|
||||
@ -162,14 +163,12 @@ export async function onRequestPost(context: RequestContext) {
|
||||
)}${Date.now()}`;
|
||||
|
||||
uploadUrlPromises.push(
|
||||
GenerateUploadURL(
|
||||
context.env,
|
||||
`t/${fileUploadKey}`,
|
||||
file.size,
|
||||
fileExten,
|
||||
origin,
|
||||
),
|
||||
upload(context.env, `t/${fileUploadKey}`, file.size, fileExten),
|
||||
);
|
||||
|
||||
if (!["mp4", "m4v", "webm"].includes(fileExten)) {
|
||||
filesToProcess.push(fileUploadKey);
|
||||
}
|
||||
}
|
||||
|
||||
const uploadUrlResults = await Promise.allSettled(uploadUrlPromises);
|
||||
@ -179,6 +178,17 @@ export async function onRequestPost(context: RequestContext) {
|
||||
)}${crypto.randomUUID().replaceAll("-", "")}`;
|
||||
|
||||
const { current_user: currentUser } = context.data;
|
||||
if (filesToProcess.length)
|
||||
await context.env.DATA.put(
|
||||
`coconutjob_${reportId}`,
|
||||
JSON.stringify({
|
||||
attachments: filesToProcess,
|
||||
token: crypto.randomUUID(),
|
||||
}),
|
||||
{
|
||||
expirationTtl: 1800,
|
||||
},
|
||||
);
|
||||
|
||||
await context.env.DATA.put(
|
||||
`reportprocessing_${reportId}`,
|
||||
|
Loading…
x
Reference in New Issue
Block a user