Commit 616d52a4 authored by Areum Kim's avatar Areum Kim
Browse files

[Issue, #36] update uploadRoutes

parent 2b862a78
Pipeline #79563 failed with stages
in 1 minute and 3 seconds
......@@ -21,40 +21,6 @@ fun NormalOpenAPIRoute.uploadRoutes() {
route("/") {
route("faqResource/{chatbotId}/create") {
post<BotIDPathParam, String, JsonReq>(
info(
summary = "Upload file",
description = "Uploads a file"
)
) { params, body ->
val handler = FileHandler(body.file)
try {
handler.parseJSON("url")
} catch (e: Exception) {
val msg = """
The uploaded file doesn't match the predefined structure. The only valid structure is:
{
"type": "url",
"name": "https://your.url",
"question": {
"type": "text",
"css_selector": "table.category > tbody td.list-title > a"
},
"answer": {
"type": "[text|href]",
"css_selector": "div.item-page > div:nth-child(5)"
}
}
The following field is missing or couldn't be parsed:
""".trimIndent()
respond(msg + e.message.toString())
}
handler.saveToFolder("faqResources/${params.chatbotId}")
}
}
route("files") {
get<Unit, List<FAQDataOut>>(
info(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment