47 lines
1.2 KiB
JavaScript
47 lines
1.2 KiB
JavaScript
import {
|
|
createContainer,
|
|
getContainers,
|
|
getBlobs,
|
|
createBlob,
|
|
uploadFile,
|
|
} from "../../../actions/azurestorage";
|
|
|
|
import middleware from "../middleware/middleware";
|
|
import nextConnect from "next-connect";
|
|
|
|
const ApiProxy = nextConnect();
|
|
ApiProxy.use(middleware);
|
|
|
|
ApiProxy.post(async (req, res) => {
|
|
var checkHash = req.query.hash;
|
|
console.log(JSON.parse(req.body.appealData));
|
|
console.log(req.files);
|
|
|
|
const appealData = JSON.parse(req.body.appealData);
|
|
|
|
// var checkquerypath = "/api/file/upload";
|
|
|
|
// console.log(hashAPIPath(checkquerypath), checkHash);
|
|
// console.log(hashAPIPath(checkquerypath) == "?hash=" + checkHash);
|
|
|
|
// if (hashAPIPath(checkquerypath) == "?hash=" + checkHash) {
|
|
createContainer(appealData.pinswg_name.trim()).then((containerName) => {
|
|
createBlob(appealData, containerName).then((data) => {
|
|
uploadFile(req.files, containerName, data);
|
|
});
|
|
});
|
|
|
|
return res.status(200).json({ data: "success" });
|
|
// } else {
|
|
// return res.status(400).json();
|
|
// }
|
|
});
|
|
|
|
export const config = {
|
|
api: {
|
|
bodyParser: false,
|
|
},
|
|
};
|
|
|
|
export default ApiProxy;
|