reps pdf upload directory restructure

This commit is contained in:
2023-10-04 14:28:56 +01:00
parent f78210c24c
commit 1f669a5efe
29 changed files with 503 additions and 670 deletions
+1 -1
View File
@@ -44,7 +44,7 @@ export default async function ApiProxy(req, res) {
// emailReplyToId: emailReplyToId,
})
.then((response) => {
console.log("thisis the response", response);
//console.log("thisis the response", response);
return res.status(200).json(data);
})
.catch((err) => {
+19 -19
View File
@@ -170,7 +170,7 @@ export default function handler(req, res) {
case "Land Owner":
repCapacity = "LO";
break;
case "LPA":
case "lpa":
repCapacity = "LPA";
break;
@@ -207,20 +207,20 @@ export default function handler(req, res) {
// code block
}
const repDate = new Date();
// const repDate = new Date();
let day = ("0" + repDate.getDate()).slice(-2);
let month = ("0" + (repDate.getMonth() + 1)).slice(-2);
let year = repDate.getFullYear();
let time =
("0" + repDate.getHours()).slice(-2) +
"" +
("0" + repDate.getMinutes()).slice(-2);
// let day = ("0" + repDate.getDate()).slice(-2);
// let month = ("0" + (repDate.getMonth() + 1)).slice(-2);
// let year = repDate.getFullYear();
// let time =
// ("0" + repDate.getHours()).slice(-2) +
// "" +
// ("0" + repDate.getMinutes()).slice(-2);
let repDateStamp = "";
repDateStamp = year + "" + month + day; //+ "-" + time;
// let repDateStamp = "";
// repDateStamp = year + "" + month + day; //+ "-" + time;
console.log(repDateStamp);
//console.log(reqBodyobj);
//if (hashAPIPath(checkquerypath) == "?hash=" + checkHash) {
// //createContainer(containerID).then((containerName) => {
@@ -228,21 +228,21 @@ export default function handler(req, res) {
console.log(
"///////////////////////////////////\n file created: \n" +
`tmp/${caseRef}_rep_${repDateStamp}_${repCapacity}_${repRaiser}_${repType}.pdf` +
`tmp/${reqBodyobj.repfile_name}.pdf` +
"\n/////////////////////////"
);
createRepBlob(req.body, containerID, caseRef);
// createRepBlob(req.body, containerID, caseRef);
ReactPDF.render(
<MyDocument docProps={reqBodyobj} />,
`tmp/${caseRef}_rep_${repDateStamp}_${repCapacity}_${repRaiser}_${repType}.pdf`
`tmp/${reqBodyobj.repfile_name}.pdf`
);
uploadPDFRepFiles(
`tmp/${caseRef}_rep_${repDateStamp}_${repCapacity}_${repRaiser}_${repType}.pdf`,
`tmp/${reqBodyobj.repfile_name}.pdf`,
containerID,
caseRef,
caseRef + "/" + reqBodyobj.repfile_name,
repType
);
@@ -250,11 +250,11 @@ export default function handler(req, res) {
// then remove from local folder
// fs.unlinkSync( `tmp/${caseRef}_rep_${repDateStamp}_${repCapacity}_${repRaiser}_${repType}.pdf`,);
// fs.unlinkSync( `tmp/${reqBodyobj.repfile_name}.pdf`,);
return res.status(200).json({
data: "success",
path: `tmp/${caseRef}_rep_${repDateStamp}_${repCapacity}_${repRaiser}_${repType}.pdf`,
path: `tmp/${reqBodyobj.repfile_name}.pdf`,
});
// } else {
// return res.status(400).json();
+1 -1
View File
@@ -58,7 +58,7 @@ ApiProxy.get(async (req, res) => {
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
const blobObj = await getRepsBlobs(containerName, casefolderID)
.then(async (data) => {
// console.log("----------xxxxxx------", data);
console.log("----------xxxxxx------", data);
let result = await downloadAllRepsFiles(containerName, data);
return res.status(200).json(result);
})