且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用多部分/混合的放心音频文件上传

更新时间:2023-01-07 17:25:12

以下是我解决此测试问题的方法:

Here's how I was able to resolve this test issue:

@Test(dependsOnGroups = {"init"})
public void uploadAudio() throws IOException{
    url = (baseURI + "/" + basePath + dataProvider.uploadAudioPath()).replaceAll("\\s","");
    logger.debug("Testing " + url);

    File file = new ClassPathResource("uploadAudio.txt").getFile();

    given()
       .contentType("multipart/mixed; boundary=\"====outer123==\"")
       .body(file)
       .pathParam("param", "14255894558")
       .header("Authorization", dataProvider.getToken()). 
    expect()
       .statusCode(200).
    when()
       .put(url);

我对其进行了测试,它在 Spring Boot 中运行良好.我希望这对其他人有帮助

I tested it and it works fine in Spring Boot. I hope this helps someone else