18

I'm try to add binary file data directly to the request body of a POST call so I can simulate a file upload. However, I tried setting a 'before request' breakpoint and using 'insert file' but I couldn't seem to get that to work. I also tried to modify CustomRules.js to inject the file but couldn't figure out how to load binary data via JScript. Is there an easy solution here?

Oliver
  • 347
  • 1
  • 4
  • 9
  • What type of upload are you doing (e.g. to what server)? Different servers accept different formats. Your best bet is to tamper with an existing upload, but it is possible to generate a properly formatted upload with Fiddler. – EricLaw Oct 11 '11 at 02:14

4 Answers4

43

I'm sure this is a new feature in the year since this question was answered, but thought I'd add it anyhow:

There's a blue "[Upload file]" link in Composer now on the right side under the URL textbox. This will create a full multipart/form-data request. If you use this, you'll notice in the body you now have something that looks like this:

<@INCLUDE C:\Some\Path\my-image.jpg@>

In my case, I just wanted to POST the binary file directly with no multipart junk, so I just put the <@INCLUDE ... @> magic in the request body, and that sends the binary file as the body.

ManicBlowfish
  • 2,258
  • 2
  • 21
  • 29
15

In order to send multipart/form-data, this receipe will be helped.

In upper panel (Http header), set Content-Type as below. Other values are automatically resolved.

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

And, input Response Body at the below panel as follows.

---------------------------acebdf13572468
Content-Disposition: form-data; name="description" 

the_text_is_here
---------------------------acebdf13572468
Content-Disposition: form-data; name="file"; filename="123.jpg"
Content-Type: image/jpg

<@INCLUDE *C:\Users\Me\Pictures\95111c18-e969-440c-81bf-2579f29b3564.jpg*@>
---------------------------acebdf13572468--

The import rules are,

  1. Content-Type should have two more - signs than boundary words in body.
  2. The last of the body should be ended with two - signs.
Youngjae
  • 24,352
  • 18
  • 113
  • 198
5

In Fiddler script: (in Fiddler: Rules... Customize Rules), find the OnBeforeRequest function, and add a line similar to:

if (oSession.uriContains("yourdomain"))
{
    oSession.LoadRequestBodyFromFile("c:\\temp\\binarycontent.dat");    
}
Tom de Waard
  • 373
  • 2
  • 7
cuixiping
  • 24,167
  • 8
  • 82
  • 93
2

since version 2.0, the Request Body has an "Upload File..." link that allows you to post/upload binary data.

AceMark
  • 701
  • 1
  • 11
  • 21