title: How to create postman multipart/form-data request with an embedded file?
body: <p>I'm creating a set of postman requests, in a collection, so that I can test an endpoint which accepts file uploads. I need to embed files in the request because otherwise the test collection isn't self contained and can't be used in the postman runner directly. </p>
  
  <p>I can "embed" text files without line breaks (CRLF) but I can't embed binary files since they contain CRLFs.</p>
  
  <p>Ways to embed single line text files</p>
  
  <ul>
  <li>Embed single line text files
  
  <ul>
  <li>This can be achieved by setting a custom header and body</li>
  </ul></li>
  </ul>
  
  <p>Header </p>
  
  <pre><code>content-type: multipart/form-data; boundary=--------------------------separator
  </code></pre>
  
  <p>Body (raw type)</p>
  
  <pre><code>----------------------------separator
  Content-Disposition: form-data; name="file"; filename="file.json"
  Content-Type: application/json
  
  { "id": "ecee0102-51c9-4a86-b5e7-0378f117f991" }
  ----------------------------separator--
  </code></pre>
  
  <ul>
  <li>"Embed" big single-line files using a pre-request script</li>
  </ul>
  
  <p>Header </p>
  
  <pre><code>content-type: multipart/form-data; boundary=--------------------------separator
  </code></pre>
  
  <p>Body (raw type)</p>
  
  <pre><code>----------------------------separator
  Content-Disposition: form-data; name="file"; filename="file.json"
  Content-Type: application/json
  
  {{tooBigFileContent}}
  ----------------------------separator--
  </code></pre>
  
  <p>Pre-request script</p>
  
  <pre><code>pm.globals.set("tooBigFileContent", "9".repeat((10*1024*1024)+1));
  </code></pre>
  
  <p>Things I have tried but didn't work</p>
  
  <ul>
  <li>Try to inject file contents into the body, decoding base64 to "binary", using pre-request script</li>
  <li>Try to use Content-Transfer-Encoding with base64 (the endpoint doesn't support the encoding</li>
  </ul>
  
  <p>Ideas on how to achieve this?</p>