IO-1998 LMS Zip Download.
This commit is contained in:
@@ -7,7 +7,7 @@ import MediaFile from "../util/interfaces/MediaFile";
|
||||
import ListableChecker from "../util/listableChecker";
|
||||
import GenerateUrl from "../util/MediaUrlGen";
|
||||
import { PathToRoFolder } from "../util/pathGenerators";
|
||||
import { FolderPaths } from "../util/serverInit";
|
||||
import { FolderPaths, JobRelativeFilePath } from "../util/serverInit";
|
||||
|
||||
export async function JobsListMedia(req: Request, res: Response) {
|
||||
const jobid: string = (req.body.jobid || "").trim();
|
||||
@@ -19,8 +19,13 @@ export async function JobsListMedia(req: Request, res: Response) {
|
||||
//We just uploaded files, we're going to send only those back.
|
||||
ret = await Promise.all(
|
||||
(req.files as Express.Multer.File[]).map(async (file) => {
|
||||
const relativeFilePath: string = JobRelativeFilePath(
|
||||
jobid,
|
||||
file.filename
|
||||
);
|
||||
|
||||
const relativeThumbPath: string = await GenerateThumbnail(
|
||||
path.join(FolderPaths.Jobs, jobid, file.filename)
|
||||
relativeFilePath
|
||||
);
|
||||
return {
|
||||
src: GenerateUrl([
|
||||
@@ -38,6 +43,7 @@ export async function JobsListMedia(req: Request, res: Response) {
|
||||
thumbnailHeight: 250,
|
||||
thumbnailWidth: 250,
|
||||
filename: file.filename,
|
||||
relativeFilePath,
|
||||
};
|
||||
})
|
||||
);
|
||||
@@ -46,15 +52,17 @@ export async function JobsListMedia(req: Request, res: Response) {
|
||||
await fs.readdir(PathToRoFolder(jobid), {
|
||||
withFileTypes: true,
|
||||
})
|
||||
).filter(
|
||||
(f) =>
|
||||
f.isFile() && !/(^|\/)\.[^\/\.]/g.test(f.name) && ListableChecker(f)
|
||||
);
|
||||
).filter((f) => f.isFile() && ListableChecker(f));
|
||||
|
||||
ret = await Promise.all(
|
||||
filesList.map(async (file) => {
|
||||
const relativeFilePath: string = JobRelativeFilePath(
|
||||
jobid,
|
||||
file.name
|
||||
);
|
||||
|
||||
const relativeThumbPath: string = await GenerateThumbnail(
|
||||
path.join(FolderPaths.Jobs, jobid, file.name)
|
||||
relativeFilePath
|
||||
);
|
||||
return {
|
||||
src: GenerateUrl([
|
||||
@@ -72,6 +80,7 @@ export async function JobsListMedia(req: Request, res: Response) {
|
||||
thumbnailHeight: 250,
|
||||
thumbnailWidth: 250,
|
||||
filename: file.name,
|
||||
relativeFilePath,
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user