[Gatling 2] Fileuploads

Hi guys,

I’m struggeling a bit with a simple multipart fileupload. I’ve tried to add a .rawBodyPart() on the post request, but it seems like this is not the thing I am looking for.

To clarify, I want to post to an URL, and attach a file from disk to a param (“fileUpload”).

This was done via the .upload-method in gatling 1.5, but I cannot seem to find the corresponding way to do it in gatling 2.

Thanks,

Andreas

We’re completely refactoring multipart support v2 and will have something stable for 2.0.0-M3.
What you have to use is rawFileBodyPart
There’s a unofficial timestamped version in Excilys’ Nexus named 2.0.0.20130606 that you can try:

http://repository.excilys.com/content/repositories/releases/io/gatling/highcharts/gatling-charts-highcharts/2.0.0.20130605/gatling-charts-highcharts-2.0.0.20130605-bundle.zip

Cheers,

Stéphane

Ok,

So basically we’ll have to construct the request “by hand”?

What do you mean, by hand?

Not very well formulated by me I’m afraid. I’ll try to explain with an example:

When uploading a file through a browser, the headers look something like this:

Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryIEYgyLofyZbvhndP

And the file-part look like this:

------WebKitFormBoundaryIEYgyLofyZbvhndP

Content-Disposition: form-data; name=“fileInput”; filename=“pdf-file.pdf”

Content-Type: application/pdf

When I try with .rawFileBodyPart(“fileInput”, “pdf-file.pdf”, “application/pdf”, “upload”) the headers look good, but the file part looks like this:

–ZFkSCQZaqPkGyCnNUZndTiF5b9Y9miM4v

Content-Type: application/pdf; charset=utf-8

Content-Transfer-Encoding: binary

Content-ID: upload

kl. 11:43:36 UTC+2 fredag 21. juni 2013 skrev Stéphane Landelle følgende:

So:

  • Content-Disposition is not generated, I’ll have to check why

  • Regarding Content-ID, just dont pass one and you won’t get one

  • Regarding Content-Type, there’s a charset=utf-8 that shouldn’t probably be there
    Does this cause your upload not to work?

It is the missing "name=“fileInput”; " that causes the upload to fail, but that is probably a part of the content disposition issue?
The back-end should be fairly agnostic to content type and charset (at least in this part of the chain).

kl. 12:42:09 UTC+2 fredag 21. juni 2013 skrev Stéphane Landelle følgende:

OK

Just one last question: which version do you use? 2.0.0-M2 or 2.0.0.20130605?

Using the timestamped one.

I’ve refactored Body and BodyParts APIs so that one gets full control over parts properties: https://github.com/excilys/gatling/issues/1238
I’ll produce a new timestamp ASAP, and we’ll probably release 2.0.0-M3 within a week from now, once we’ll have properly tested it.

Cheers,

Stéphane

Again, thanks a million Stéphane!

I’m going to test this asap!

Andreas

kl. 12:32:20 UTC+2 mandag 24. juni 2013 skrev Stéphane Landelle følgende: