I have the following code snippet:
@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 + "!!";
}
Now I want to test whether the upload works. How can I do this? How would be the syntax when I try it with curl?
Source: https://www.mkyong.com/spring/curl-post-request-examples/
To POST with a file, add this -F file=@"path/to/data.txt"
$ curl -F file=@"path/to/data.txt" http://localhost:8080/dropbox/upload
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.