c++ - Pistache 服务器如何处理文件上传?
问题描述
我在 openapi 3.0 中创建了一个用于文件上传的 api。我的 YAML 文件如下所示
paths:
/upload:
post:
description: Upload a single Audio File
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
upload:
type: string
format: binary
responses:
'200':
description: Successful to Upload file
'400':
description: Fail to Upload File
在服务器端,我的文件上传部分现在看起来像这样
void DefaultApiImpl::upload_post(const Pistache::Rest::Request &request, Pistache::Http::ResponseWriter &response){
response.send(Pistache::Http::Code::Ok, "File Upload Complete..................... \n");
}
当我尝试使用 api 上传任何文件时,我也会得到响应。问题是我没有为服务器端获取任何资源来将文件存储在特定文件夹或目标中。我在服务器端缺少什么?
解决方案
推荐阅读
- python-3.x - 桌面通知win10toast图像不起作用
- mysql - 有没有办法在同一个共享托管服务器上将一个数据库设置为 Antelope,另一个数据库设置为梭子鱼?
- python - 如何从 numpy.ndarray 确定图像格式?
- api - 如何解决在 Flutter 中编译移动应用程序时遇到的错误?
- r - 为什么 nrow() 返回 NULL 值?
- javascript - 退出屏幕时撤消重新渲染
- eclipse - 如何有效地移动键盘光标
- python-3.x - 即使使用默认值,创建新对象也会保留数据
- winapi - 为什么 AccessibleChildren 不返回与指定数量相同的元素?
- c# - SQL 运行 EXE 有效。当 Exe 启动另一个 Exe 时挂起