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

@@ -22,17 +22,10 @@ export async function BillsListMedia(req: Request, res: Response) {
if (req.files) {
ret = await Promise.all(
(req.files as Express.Multer.File[]).map(async (file) => {
const relativeFilePath: string = path.join(
PathToRoBillsFolder(jobid),
file.filename
);
const relativeFilePath: string = path.join(PathToRoBillsFolder(jobid), file.filename);
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);
return {
type,
size: file.size,
@@ -41,72 +34,57 @@ export async function BillsListMedia(req: Request, res: Response) {
FolderPaths.JobsFolder,
jobid,
FolderPaths.BillsSubDir,
file.filename,
file.filename
]),
thumbnail: GenerateUrl([
FolderPaths.StaticPath,
FolderPaths.JobsFolder,
jobid,
FolderPaths.BillsSubDir,
relativeThumbPath,
relativeThumbPath
]),
thumbnailHeight: 250,
thumbnailWidth: 250,
filename: file.filename,
relativeFilePath,
relativeFilePath
};
})
);
} else {
let filesList: fs.Dirent[] = (
await fs.readdir(PathToRoBillsFolder(jobid), {
withFileTypes: true,
withFileTypes: true
})
).filter(
(f) =>
f.isFile() &&
!/(^|\/)\.[^\/\.]/g.test(f.name) &&
(invoice_number !== ""
? f.name.toLowerCase().includes(invoice_number.toLowerCase())
: true) &&
(invoice_number !== "" ? f.name.toLowerCase().includes(invoice_number.toLowerCase()) : true) &&
ListableChecker(f)
);
ret = await Promise.all(
filesList.map(async (file) => {
const relativeFilePath: string = path.join(
PathToRoBillsFolder(jobid),
file.name
);
const relativeFilePath: string = path.join(PathToRoBillsFolder(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,
FolderPaths.BillsSubDir,
file.name,
]),
src: GenerateUrl([FolderPaths.StaticPath, FolderPaths.JobsFolder, jobid, FolderPaths.BillsSubDir, file.name]),
thumbnail: GenerateUrl([
FolderPaths.StaticPath,
FolderPaths.JobsFolder,
jobid,
FolderPaths.BillsSubDir,
relativeThumbPath,
relativeThumbPath
]),
thumbnailHeight: 250,
thumbnailWidth: 250,
filename: file.name,
relativeFilePath,
relativeFilePath
};
})
);