Add logging, pdf thumbs
This commit is contained in:
@@ -14,37 +14,27 @@ export async function JobsListMedia(req: Request, res: Response) {
|
||||
})
|
||||
).filter((f) => f.isFile() && !/(^|\/)\.[^\/\.]/g.test(f.name));
|
||||
|
||||
const thumbnailGenerationQueue: Promise<void>[] = [];
|
||||
|
||||
const ret: MediaFile[] = filesList.map((file) => {
|
||||
thumbnailGenerationQueue.push(
|
||||
GenerateThumbnail(
|
||||
path.join(FolderPaths.Jobs, ro_number, file.name),
|
||||
path.join(
|
||||
FolderPaths.Jobs,
|
||||
const ret: MediaFile[] = await Promise.all(
|
||||
filesList.map(async (file) => {
|
||||
const thumbPath: string = await GenerateThumbnail(
|
||||
path.join(FolderPaths.Jobs, ro_number, file.name)
|
||||
);
|
||||
return {
|
||||
src: GenerateUrl([
|
||||
FolderPaths.StaticPath,
|
||||
FolderPaths.JobsFolder,
|
||||
ro_number,
|
||||
FolderPaths.ThumbsSubDir,
|
||||
file.name
|
||||
)
|
||||
)
|
||||
);
|
||||
return {
|
||||
src: GenerateUrl([
|
||||
FolderPaths.StaticPath,
|
||||
FolderPaths.JobsFolder,
|
||||
ro_number,
|
||||
file.name,
|
||||
]),
|
||||
thumb: GenerateUrl([
|
||||
FolderPaths.StaticPath,
|
||||
FolderPaths.JobsFolder,
|
||||
ro_number,
|
||||
FolderPaths.ThumbsSubDir,
|
||||
file.name,
|
||||
]),
|
||||
};
|
||||
});
|
||||
await Promise.all(thumbnailGenerationQueue);
|
||||
file.name,
|
||||
]),
|
||||
thumb: GenerateUrl([
|
||||
FolderPaths.StaticPath,
|
||||
FolderPaths.JobsFolder,
|
||||
ro_number,
|
||||
thumbPath,
|
||||
]),
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
res.json(ret);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Request, Response } from "express";
|
||||
import multer from "multer";
|
||||
import path from "path";
|
||||
import { logger } from "../server";
|
||||
import GenerateThumbnail from "../util/generateThumbnail";
|
||||
import { FolderPaths } from "../util/serverInit";
|
||||
import { JobsListMedia } from "./jobsListMedia";
|
||||
@@ -13,7 +14,7 @@ export const JobMediaUploadMulter = multer({
|
||||
cb(null, DestinationFolder);
|
||||
},
|
||||
filename: function (req, file, cb) {
|
||||
console.log(path.basename(file.originalname));
|
||||
logger.info("Uploading file: ", path.basename(file.originalname));
|
||||
cb(
|
||||
null,
|
||||
`${file.originalname}-${Math.floor(Date.now() / 1000)}.${path.extname(
|
||||
@@ -34,21 +35,11 @@ export async function jobsUploadMedia(req: Request, res: Response) {
|
||||
message: "No file uploaded",
|
||||
});
|
||||
} else {
|
||||
const thumbnailGenerationQueue: Promise<void>[] = [];
|
||||
const thumbnailGenerationQueue: Promise<string>[] = [];
|
||||
|
||||
//for each file.path, generate the thumbnail.
|
||||
(req.files as Express.Multer.File[]).forEach((file) => {
|
||||
thumbnailGenerationQueue.push(
|
||||
GenerateThumbnail(
|
||||
file.path,
|
||||
path.join(
|
||||
FolderPaths.Jobs,
|
||||
ro_number,
|
||||
FolderPaths.ThumbsSubDir,
|
||||
file.originalname
|
||||
)
|
||||
)
|
||||
);
|
||||
thumbnailGenerationQueue.push(GenerateThumbnail(file.path));
|
||||
});
|
||||
await Promise.all(thumbnailGenerationQueue);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user