59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
import {
|
|
createBlob,
|
|
createRepBlob,
|
|
uploadFile,
|
|
} from "../../../actions/azurestorage";
|
|
|
|
import nextConnect from "next-connect";
|
|
import middleware from "../middleware/middleware";
|
|
|
|
const ApiProxy = nextConnect();
|
|
ApiProxy.use(middleware);
|
|
|
|
ApiProxy.post(async (req, res) => {
|
|
var checkHash = req.query.hash;
|
|
//console.log(JSON.stringify(req.body));
|
|
//console.log(JSON.stringify(req.body.appealData));
|
|
//console.log(req.files);
|
|
|
|
const appealData = req.body.appealData;
|
|
const containerID = req.body.containerID[0];
|
|
const casefolderID = req.body.casefolderID[0];
|
|
const repOrAppeal = req.body.repOrAppeal || false;
|
|
|
|
console.log("there are files:", Object.keys(req.files).length);
|
|
|
|
// var checkquerypath = "/api/file/upload";
|
|
|
|
//console.log(hashAPIPath(checkquerypath), checkHash);
|
|
//console.log(hashAPIPath(checkquerypath) == "?hash=" + checkHash);
|
|
|
|
// if (hashAPIPath(checkquerypath) == "?hash=" + checkHash) {
|
|
//createContainer(containerID).then((containerName) => {
|
|
|
|
console.log("does this get folder name:", containerID, casefolderID);
|
|
repOrAppeal
|
|
? createRepBlob(appealData, containerID, casefolderID).then((data) => {
|
|
Object.keys(req.files).length > 0 &&
|
|
uploadFile(req.files, containerID, casefolderID);
|
|
})
|
|
: createBlob(appealData, containerID, casefolderID).then((data) => {
|
|
Object.keys(req.files).length > 0 &&
|
|
uploadFile(req.files, containerID, casefolderID);
|
|
});
|
|
//});
|
|
|
|
return res.status(200).json({ data: "success" });
|
|
// } else {
|
|
// return res.status(400).json();
|
|
// }
|
|
});
|
|
|
|
export const config = {
|
|
api: {
|
|
bodyParser: false,
|
|
},
|
|
};
|
|
|
|
export default ApiProxy;
|