所以我有一個 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是上傳到服務器!我究竟做錯了什么?我查過谷歌,但看起來我幾乎什么都做了。
上傳文件的cURL命令不上傳文件
慕田峪9158850
2022-11-30 16:54:41