-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PS-2796 fix: Handling get-status API in admin app ZIP file upload
- Loading branch information
1 parent
f6b5f39
commit 942af90
Showing
2 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
export default async function handler(req, res) { | ||
if (req.method === "POST") { | ||
try { | ||
const { contenturl } = req.body; | ||
|
||
// Split the URL by slashes and extract the second last part | ||
const parts = contenturl.split("/"); | ||
const doId = parts.length > 2 ? parts[parts.length - 2] : null; | ||
if (doId) { | ||
const baseURL = process.env.NEXT_PUBLIC_MIDDLEWARE_URL; | ||
|
||
const axios = require("axios"); | ||
|
||
let config = { | ||
method: "get", | ||
maxBodyLength: Infinity, | ||
url: `${baseURL}/api/content/v1/read/${doId}?fields=artifactUrl`, | ||
headers: { | ||
}, | ||
}; | ||
|
||
await axios | ||
.request(config) | ||
.then((response) => { | ||
console.log(JSON.stringify(response.data)); | ||
if (response?.data?.result?.content?.artifactUrl != null) { | ||
res.status(200).json({ doId, success: true }); | ||
} else { | ||
res.status(200).json({ doId, success: false }); | ||
} | ||
}) | ||
.catch((error) => { | ||
res.status(200).json({ doId, success: false }); | ||
}); | ||
} else { | ||
res.status(200).json({ doId, success: false }); | ||
} | ||
} catch (error) { | ||
console.error("Error", error); | ||
res.status(500).json({ error: error.message }); | ||
} | ||
} else { | ||
res.status(405).json({ error: "Method not allowed" }); | ||
} | ||
} |