2017-01-28 13 views
0

"file"という名前のフォームデータパラメータ内に複数の画像をアップロードできるpost API呼び出しがあります 郵便受けでは、キー "ファイル"を持つフォームデータで複数のファイルを送信できます。複数のファイルとしての値安心して複数のファイルをアップロード

安心のJavaクライアントで同じ呼び出しをシミュレートしたいと思います。 1つのファイルを安心してアップロードできますが、複数のファイルをアップロードすることはできません。任意の助けをいただければ幸いです

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"); 
関連する問題