[英]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.