所以我有一个 Java API,我使用 cURL 命令向我的 API 发送 GET/POST 请求。我在我的 Java API 中使用 Springboot。我的 cURL 命令如下所示:
curl -X POST \
https://localhost:8443/abc/code/v \
-H 'Content-Type: multipart/form-data' \
-F file=@/path/to/file.txt
接收此请求的 Java Springboot 方法如下所示:
@RequestMapping(method = RequestMethod.POST, value = "/{code}/{v}")
public ResponseEntity<Object> uploadTemplate( //
@ApiParam(value = "code desc") //
@PathVariable final String code, //
@ApiParam(value = "v desc") //
@PathVariable final String v, //
@RequestParam("file") MultipartFile file
) throws IOException {
//log.info("received [url: /tabc/" + code + "/" + v + ", method: POST");
System.out.println("file: "+ file.getName());
}
打印出来"file: file"
它看起来根本不像file.txt是上传到服务器!我究竟做错了什么?我查过谷歌,但看起来我几乎什么都做了。
弑天下
相关分类