Added bills upload & list
This commit is contained in:
@@ -3,24 +3,22 @@ import multer from "multer";
|
||||
import path from "path";
|
||||
import { logger } from "../server";
|
||||
import GenerateThumbnail from "../util/generateThumbnail";
|
||||
import { FolderPaths } from "../util/serverInit";
|
||||
import generateUniqueFilename from "../util/generateUniqueFilename";
|
||||
import { PathToRoFolder } from "../util/pathGenerators";
|
||||
import { JobsListMedia } from "./jobsListMedia";
|
||||
import fs from "fs-extra";
|
||||
|
||||
export const JobMediaUploadMulter = multer({
|
||||
storage: multer.diskStorage({
|
||||
destination: function (req, file, cb) {
|
||||
const ro_number: string = (req.body.ro_number || "").trim();
|
||||
const DestinationFolder: string = path.join(FolderPaths.Jobs, ro_number);
|
||||
const DestinationFolder: string = PathToRoFolder(ro_number);
|
||||
fs.ensureDirSync(DestinationFolder);
|
||||
cb(null, DestinationFolder);
|
||||
},
|
||||
filename: function (req, file, cb) {
|
||||
logger.info("Uploading file: ", path.basename(file.originalname));
|
||||
cb(
|
||||
null,
|
||||
`${file.originalname}-${Math.floor(Date.now() / 1000)}.${path.extname(
|
||||
file.originalname
|
||||
)}`
|
||||
);
|
||||
cb(null, generateUniqueFilename(file));
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user