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 { jsonError, jsonResponse } from "../../common.js";
|
||||||
|
import upload from "../upload.js";
|
||||||
|
|
||||||
export async function onRequestPost(context: RequestContext) {
|
export async function onRequestPost(context: RequestContext) {
|
||||||
const {
|
const {
|
||||||
@ -137,6 +137,7 @@ export async function onRequestPost(context: RequestContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const uploadUrlPromises: Promise<string>[] = [];
|
const uploadUrlPromises: Promise<string>[] = [];
|
||||||
|
const filesToProcess = [];
|
||||||
|
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
const fileParts = file.name.split(".");
|
const fileParts = file.name.split(".");
|
||||||
@ -162,14 +163,12 @@ export async function onRequestPost(context: RequestContext) {
|
|||||||
)}${Date.now()}`;
|
)}${Date.now()}`;
|
||||||
|
|
||||||
uploadUrlPromises.push(
|
uploadUrlPromises.push(
|
||||||
GenerateUploadURL(
|
upload(context.env, `t/${fileUploadKey}`, file.size, fileExten),
|
||||||
context.env,
|
|
||||||
`t/${fileUploadKey}`,
|
|
||||||
file.size,
|
|
||||||
fileExten,
|
|
||||||
origin,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!["mp4", "m4v", "webm"].includes(fileExten)) {
|
||||||
|
filesToProcess.push(fileUploadKey);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const uploadUrlResults = await Promise.allSettled(uploadUrlPromises);
|
const uploadUrlResults = await Promise.allSettled(uploadUrlPromises);
|
||||||
@ -179,6 +178,17 @@ export async function onRequestPost(context: RequestContext) {
|
|||||||
)}${crypto.randomUUID().replaceAll("-", "")}`;
|
)}${crypto.randomUUID().replaceAll("-", "")}`;
|
||||||
|
|
||||||
const { current_user: currentUser } = context.data;
|
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(
|
await context.env.DATA.put(
|
||||||
`reportprocessing_${reportId}`,
|
`reportprocessing_${reportId}`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user