2017-01-28 4 views
0

"file"이라는 양식 데이터 매개 변수 내에 여러 이미지를 업로드 할 수있는 게시 API 호출이 있습니다 우편 배달부에서 키 "파일"이있는 양식 데이터로 여러 파일을 보낼 수 있습니다. 및 값을 여러 파일로안심할 수있는 여러 파일 업로드

안심 자바 클라이언트와 동일한 호출을 시뮬레이트하고 싶습니다. 안심할 수 있지만 여러 파일을 업로드 할 수없는 단일 파일을 업로드 할 수 있습니다. 어떤 도움을 주시면 감사하겠습니다

File sheetFile = new File(sheetPath.get(0)); 
response = RestAssured. 
      given(). 
       headers(headers). 
       formParameter("studentDetail", 
         "{"+ 
         "\"userId\" : "+PropFileHandler.readProperty("psUserId")+ 
         ",\"institutionId\" : "+PropFileHandler.readProperty("institution_id")+ 
         ",\"externalUserId\" : "+PropFileHandler.readProperty("user_id")+ 
         ",\"tokenId\" : \"12000\""+ 
         ",\"imagePathStatus\" : \"\""+ 
         "}"). 
       formParameter("clientType", getData("ps_bulk_upload_image.clientType")). 
       multiPart("file", sheetFile). #here i want to upload multile files 
      when(). 
       post(relativePath). 
      then(). 
       statusCode(200). 
       body(matchesJsonSchema(new File(test.cngActions.getJsonSchemaDirectoryPath()+ 
         getData("ps_bulk_upload_image.schemaPath")))). 
       extract().response(); 

:

다음은 단일 파일 업로드 나머지 안심 코드입니다.

답변

0

multiPart 번으로 전화하면됩니다.

는 여기를 참조하십시오 : https://blog.jayway.com/2011/09/15/multipart-form-data-file-uploading-made-simple-with-rest-assured/

관련 코드 :

given(). 
    multiPart("file1", new File("/home/johan/some_large_file.bin")). 
    multiPart("file2", new File("/home/johan/some_other_large_file.bin")). 
    multiPart("file3", "file_name.bin", inputStream). 
    formParam("name", "value"). 
expect(). 
    body("fileUploadResult", is("OK")). 
when(). 
    post("/advancedFileUpload");