如何使用Spring Boot在Java中测试Dropbox上传?

问题描述 投票:0回答:1

我有以下代码段:

@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时,语法如何?

java spring-boot dropbox
1个回答
0
投票

来源:https://www.mkyong.com/spring/curl-post-request-examples/

要使用文件进行POST,请添加此-F文件= @“ path / to / data.txt”

$ curl -F file=@"path/to/data.txt" http://localhost:8080/dropbox/upload
© www.soinside.com 2019 - 2024. All rights reserved.