[英]How to test a dropbox upload in Java with Spring Boot?
我有以下代码片段:
@RestController
@RequestMapping("/dropbox")
public class DropboxController {
private static final Logger logger = LoggerFactory.getLogger(DropboxController.class);
@Autowired
DropboxService dropboxService;
@Autowired
DbxClientV2 dropboxClient;
@PostMapping("/upload")
public String handleFileUplad(@RequestParam("file") MultipartFile file, @RequestParam("filePath") String filePath) throws Exception {
dropboxService.uploadFile(file, filePath);
return "You successfully uploaded " + filePath + "!!";
}
现在我想测试上传是否有效。 我怎样才能做到这一点? 当我尝试使用 curl 时,语法会如何?
资料来源: https://www.mkyong.com/spring/curl-post-request-examples/
要使用文件发布,请添加此 -F file=@"path/to/data.txt"
$ curl -F file=@"path/to/data.txt" http://localhost:8080/dropbox/upload
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.