import { createBlob, createRepBlob, uploadFile } from "../../../actions/azurestorage"; import { hashAPIPath } from "../../../actions/core/hash"; 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; var checkquerypath = "/api/file/upload"; if (hashAPIPath(checkquerypath) != "?hash=" + checkHash) { return res.status(400).json(); } const appealData = req.body.appealData; const containerID = req.body?.containerID?.[0]; const casefolderID = req.body?.casefolderID?.[0]; const repOrAppeal = req.body.repOrAppeal || false; if ( typeof containerID === "undefined" || containerID.length === 0 || typeof casefolderID === "undefined" || casefolderID.length === 0 ) { return res.status(400).json(); } repOrAppeal ? createRepBlob(appealData, containerID, casefolderID).then((data) => { // Object.keys(req.files).length > 0 && // uploadFile(req.files, containerID, casefolderID).then( // (data) => { // return res.status(200).json({ data }); // } // ); return res.status(200).json({ data }); }) : createBlob(appealData, containerID, casefolderID).then((data) => { // Object.keys(req.files).length > 0 && // uploadFile(req.files, containerID, casefolderID).then( // (data) => { // return res.status(200).json({ data }); // } // ); return res.status(200).json({ data }); }); }); export const config = { api: { bodyParser: false } }; export default ApiProxy;