IO-2221 IO-2323 Correct Download/Delete/Move functions

This commit is contained in:
Allan Carr
2023-07-20 11:19:21 -07:00
parent a678383dee
commit aa3b567a5b
9 changed files with 415 additions and 334 deletions

View File

@@ -1,14 +1,14 @@
import { Request, Response } from "express";
import ft from "file-type";
import core from "file-type/core";
import fs from "fs-extra";
import path, { relative } from "path";
import GenerateUrl from "../util/MediaUrlGen";
import GenerateThumbnail from "../util/generateThumbnail";
import MediaFile from "../util/interfaces/MediaFile";
import ListableChecker from "../util/listableChecker";
import GenerateUrl from "../util/MediaUrlGen";
import { PathToRoBillsFolder, PathToRoFolder } from "../util/pathGenerators";
import { PathToRoBillsFolder } from "../util/pathGenerators";
import { FolderPaths } from "../util/serverInit";
import core from "file-type/core";
import ft from "file-type";
/** @description Bills will use the hierarchy of PDFs stored under the Job first, and then the Bills folder. */
export async function BillsListMedia(req: Request, res: Response) {
@@ -35,6 +35,7 @@ export async function BillsListMedia(req: Request, res: Response) {
);
return {
type,
size: file.size,
src: GenerateUrl([
FolderPaths.StaticPath,
FolderPaths.JobsFolder,
@@ -52,6 +53,7 @@ export async function BillsListMedia(req: Request, res: Response) {
thumbnailHeight: 250,
thumbnailWidth: 250,
filename: file.filename,
relativeFilePath,
};
})
);
@@ -83,9 +85,10 @@ export async function BillsListMedia(req: Request, res: Response) {
const type: core.FileTypeResult | undefined = await ft.fromFile(
relativeFilePath
);
const fileSize = await fs.stat(relativeFilePath);
return {
type,
size: fileSize.size,
src: GenerateUrl([
FolderPaths.StaticPath,
FolderPaths.JobsFolder,
@@ -103,6 +106,7 @@ export async function BillsListMedia(req: Request, res: Response) {
thumbnailHeight: 250,
thumbnailWidth: 250,
filename: file.name,
relativeFilePath,
};
})
);