# \[Gatling 2\] Fileuploads

**URL:** <https://community.gatling.io/t/gatling-2-fileuploads/453>\
**Category:** Gatling (Open-Source)\
**Created:** [June 21, 2013, 8:39am UTC](https://community.gatling.io/t/gatling-2-fileuploads/453 "2013-06-21T08:39:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andreas\_Heim](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Andreas\_Heim](https://community.gatling.io/u/Andreas_Heim)\
**Post date:** [June 21, 2013, 8:39am UTC](https://community.gatling.io/t/gatling-2-fileuploads/453/1 "2013-06-21T08:39:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [June 21, 2013, 9:26am UTC](https://community.gatling.io/t/gatling-2-fileuploads/453/2 "2013-06-21T09:26:02Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Andreas\_Heim](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Andreas\_Heim](https://community.gatling.io/u/Andreas_Heim)\
**Post date:** [June 21, 2013, 9:31am UTC](https://community.gatling.io/t/gatling-2-fileuploads/453/3 "2013-06-21T09:31:58Z")

</div>

Ok,

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

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [June 21, 2013, 9:43am UTC](https://community.gatling.io/t/gatling-2-fileuploads/453/4 "2013-06-21T09:43:36Z")

</div>

What do you mean, by hand?

---

<div class="post-metadata">

**Author:** ![Andreas\_Heim](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Andreas\_Heim](https://community.gatling.io/u/Andreas_Heim)\
**Post date:** [June 21, 2013, 10:28am UTC](https://community.gatling.io/t/gatling-2-fileuploads/453/5 "2013-06-21T10:28:39Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [June 21, 2013, 10:42am UTC](https://community.gatling.io/t/gatling-2-fileuploads/453/6 "2013-06-21T10:42:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Andreas\_Heim](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Andreas\_Heim](https://community.gatling.io/u/Andreas_Heim)\
**Post date:** [June 21, 2013, 10:46am UTC](https://community.gatling.io/t/gatling-2-fileuploads/453/7 "2013-06-21T10:46:50Z")

</div>

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:

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [June 21, 2013, 10:52am UTC](https://community.gatling.io/t/gatling-2-fileuploads/453/8 "2013-06-21T10:52:48Z")

</div>

OK

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

---

<div class="post-metadata">

**Author:** ![Andreas\_Heim](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Andreas\_Heim](https://community.gatling.io/u/Andreas_Heim)\
**Post date:** [June 21, 2013, 12:51pm UTC](https://community.gatling.io/t/gatling-2-fileuploads/453/9 "2013-06-21T12:51:56Z")

</div>

Using the timestamped one.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [June 24, 2013, 10:32am UTC](https://community.gatling.io/t/gatling-2-fileuploads/453/10 "2013-06-24T10:32:20Z")

</div>

I’ve refactored Body and BodyParts APIs so that one gets full control over parts properties: [https://github.com/excilys/gatling/issues/1238](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

---

<div class="post-metadata">

**Author:** ![Andreas\_Heim](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@Andreas\_Heim](https://community.gatling.io/u/Andreas_Heim)\
**Post date:** [June 25, 2013, 9:01am UTC](https://community.gatling.io/t/gatling-2-fileuploads/453/11 "2013-06-25T09:01:35Z")

</div>

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:
