I face an issue with upload file when request limit the file only 1mb. It’s mean if i upload a file with 1mb, just create one request. If I upload a file 3mb then request create 3 request to divide the file. etc…
This is my script for upload file, it work fine when image < 1mb:
val UploadFilesInCls = exec(session => { val fileResourcePath = Paths.get(baseResourscesPath).toString; val someFile = new File(fileResourcePath) session.set(“fileResourcePath”, fileResourcePath) })
def UploadFiles(baseUrl: String, csrfToken: String) = http(“Upload file on community page”) .post(baseUrl + “/file/file/upload”) .headers(headerSocialCollaborationUploadFile) .header(“X-CSRF-Token”, csrfToken) .formUpload(“files[]”, “${fileResourcePath}/${fileName}”)
And the request header when i upload more than 1mb:
Request URL: https://mysite.xyz/file/file/upload
Request Method: POST
Status Code: 200
content-disposition: attachment; filename=“image_1mb_4.jpg”
content-length: 900192
content-range: bytes 0-899999/2182674
content-type: multipart/form-data; boundary=----WebKitFormBoundaryq7EKfTV0MbgSpVNr
Request URL: https://mysite.xyz/file/file/upload
Request Method: POST
Status Code: 200
content-disposition: attachment; filename=“image_1mb_4.jpg”
content-length: 900192
content-range: bytes 900000-1799999/2182674
content-type: multipart/form-data; boundary=----WebKitFormBoundaryo4s0XFtwBp4JNA5U
Request URL: https://mysite.xyz/file/file/upload
Request Method: POST
Status Code: 200
content-disposition: attachment; filename=“image_1mb_4.jpg”
content-length: 382866
content-range: bytes 1800000-2182673/2182674
content-type: multipart/form-data; boundary=----WebKitFormBoundary6gG7Uv4WMa4zp6WN
I try using .header(“Transfer-Encoding”, “chunked”) seem as it do not work, please advice.
Not necessarily. The most efficient way would be to prepare the chunks upstream prior to running the actual load test. You can do that in whatever technology suits you.
I had split the image file to 3 parts, and send it in to 3 requests. All request response is OK, but the body is empty instead return some information (id, name,…).
My script is:
def UploadFiles1(baseUrl: String, csrfToken: String)
= http(“Upload 1”)
.post(baseUrl + “/file/file/upload”)
.headers(headerSocialCollaborationUploadFile1)
.header(“X-CSRF-Token”, csrfToken)
.body(RawFileBody(“C:/projects/MOE/07_SPT/cx-opal-gatling-Release_2.2/user-files/resources/test0104/0001_request.dat”))