Java 如何正确使用CURL在Dropbox中调用fileupload?
我有以下映射:Java 如何正确使用CURL在Dropbox中调用fileupload?,java,curl,dropbox,Java,Curl,Dropbox,我有以下映射: @PostMapping("/upload") public String handleFileUpload(@RequestParam("file") MultipartFile file, @RequestParam("filePath") String filePath) throws Exception { dropboxService.uploadFile(file, filePath); return "You successfully uploade
@PostMapping("/upload")
public String handleFileUpload(@RequestParam("file") MultipartFile file, @RequestParam("filePath") String filePath) throws Exception {
dropboxService.uploadFile(file, filePath);
return "You successfully uploaded " + filePath + "!!";
}
例如,当我尝试时:
curl --data "file=/Users/admin/Documents/sun.jpg&&filepath=/a" localhost:8080/dropbox/upload
我收到500错误-当前请求不是多部分请求
如何使用CURL正确地调用它?对于文件上载:
curl --form "fileupload=@filename.txt" http://hostname/resource
但是我需要包括params文件和filepath!要获取文件路径,请使用以下命令:file.path但如果需要同时发送file和filepath,则需要使用所有需要的字段(MultipartFile file,String filepath)创建一个DTO,并使用@ResponseBody DTO DTO更改控制器参数,并使用如下命令:curl--data“file=@filename.txt&filepath=path”