TASK22102: slice7 complex file handler contract closeout
This commit is contained in:
+31
-22
@@ -4,6 +4,7 @@ import {
|
||||
uploadFile
|
||||
} from "../../../actions/azurestorage";
|
||||
import { hashAPIPath } from "../../../actions/core/hash";
|
||||
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
||||
|
||||
import nextConnect from "next-connect";
|
||||
import middleware from "../middleware/middleware";
|
||||
@@ -15,13 +16,21 @@ ApiProxy.post(async (req, res) => {
|
||||
var checkHash = req.query.hash;
|
||||
|
||||
if (typeof checkHash === "undefined" || checkHash.length === 0) {
|
||||
return res.status(400).json();
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "HASH_REQUIRED",
|
||||
message: "hash is required"
|
||||
});
|
||||
}
|
||||
|
||||
var checkquerypath = "/api/file/upload";
|
||||
|
||||
if (hashAPIPath(checkquerypath) != "?hash=" + checkHash) {
|
||||
return res.status(400).json();
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "INVALID_HASH",
|
||||
message: "Invalid hash"
|
||||
});
|
||||
}
|
||||
|
||||
const appealData = req.body.appealData;
|
||||
@@ -35,28 +44,28 @@ ApiProxy.post(async (req, res) => {
|
||||
typeof casefolderID === "undefined" ||
|
||||
casefolderID.length === 0
|
||||
) {
|
||||
return res.status(400).json();
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "MISSING_REQUIRED_BODY",
|
||||
message: "containerID and casefolderID are required"
|
||||
});
|
||||
}
|
||||
|
||||
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 });
|
||||
});
|
||||
return (
|
||||
repOrAppeal
|
||||
? createRepBlob(appealData, containerID, casefolderID)
|
||||
: createBlob(appealData, containerID, casefolderID)
|
||||
)
|
||||
.then((data) => {
|
||||
return respondSuccess(res, { data });
|
||||
})
|
||||
.catch(() => {
|
||||
return respondError(res, {
|
||||
status: 400,
|
||||
code: "UPLOAD_FAILED",
|
||||
message: "Failed to upload blob"
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export const config = {
|
||||
|
||||
Reference in New Issue
Block a user