Package Updates

This commit is contained in:
Allan Carr
2024-07-23 09:49:47 -07:00
parent f295488195
commit 58055fd1b3
22 changed files with 1686 additions and 3807 deletions

View File

@@ -20,81 +20,47 @@ 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 relativeFilePath: string = JobRelativeFilePath(jobid, file.filename);
const relativeThumbPath: string = await GenerateThumbnail(
relativeFilePath
);
const relativeThumbPath: string = await GenerateThumbnail(relativeFilePath);
const type: core.FileTypeResult | undefined = await ft.fromFile(
relativeFilePath
);
const type: core.FileTypeResult | undefined = await ft.fileTypeFromFile(relativeFilePath);
return {
type,
size: file.size,
src: GenerateUrl([
FolderPaths.StaticPath,
FolderPaths.JobsFolder,
jobid,
file.filename,
]),
thumbnail: GenerateUrl([
FolderPaths.StaticPath,
FolderPaths.JobsFolder,
jobid,
relativeThumbPath,
]),
src: GenerateUrl([FolderPaths.StaticPath, FolderPaths.JobsFolder, jobid, file.filename]),
thumbnail: GenerateUrl([FolderPaths.StaticPath, FolderPaths.JobsFolder, jobid, relativeThumbPath]),
thumbnailHeight: 250,
thumbnailWidth: 250,
filename: file.filename,
relativeFilePath,
relativeFilePath
};
})
);
} else {
const filesList: fs.Dirent[] = (
await fs.readdir(PathToRoFolder(jobid), {
withFileTypes: true,
withFileTypes: true
})
).filter((f) => f.isFile() && ListableChecker(f));
ret = await Promise.all(
filesList.map(async (file) => {
const relativeFilePath: string = JobRelativeFilePath(
jobid,
file.name
);
const relativeFilePath: string = JobRelativeFilePath(jobid, file.name);
const relativeThumbPath: string = await GenerateThumbnail(
relativeFilePath
);
const type: core.FileTypeResult | undefined = await ft.fromFile(
relativeFilePath
);
const relativeThumbPath: string = await GenerateThumbnail(relativeFilePath);
const type: core.FileTypeResult | undefined = await ft.fileTypeFromFile(relativeFilePath);
const fileSize = await fs.stat(relativeFilePath);
return {
type,
size: fileSize.size,
src: GenerateUrl([
FolderPaths.StaticPath,
FolderPaths.JobsFolder,
jobid,
file.name,
]),
thumbnail: GenerateUrl([
FolderPaths.StaticPath,
FolderPaths.JobsFolder,
jobid,
relativeThumbPath,
]),
src: GenerateUrl([FolderPaths.StaticPath, FolderPaths.JobsFolder, jobid, file.name]),
thumbnail: GenerateUrl([FolderPaths.StaticPath, FolderPaths.JobsFolder, jobid, relativeThumbPath]),
thumbnailHeight: 250,
thumbnailWidth: 250,
filename: file.name,
relativeFilePath,
relativeFilePath
};
})
);