# Posting PDF-files multipart/form-data

**URL:** <https://discourse.nodered.org/t/posting-pdf-files-multipart-form-data/42033>\
**Category:** General\
**Created:** [4 March 2021 16:43 UTC](https://discourse.nodered.org/t/posting-pdf-files-multipart-form-data/42033 "2021-03-04T16:43:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![KjellBrandes](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kjellbrandes/32/36052_2.png) [@KjellBrandes](https://discourse.nodered.org/u/KjellBrandes)\
**Post date:** [4 March 2021 16:43 UTC](https://discourse.nodered.org/t/posting-pdf-files-multipart-form-data/42033/1 "2021-03-04T16:43:48Z")

</div>

I have a problem when trying to post a PDF-file in multipart/form-data.  
Below code in a function node:

```auto
msg.headers = {};
msg.headers['Content-Type'] = "multipart/form-data; boundary=------------------------d74496d66958873e";
msg.headers['Authorization'] = 'Bearer '+msg.token;

msg.payload = '--------------------------d74496d66958873e'+
'\r\n'+
'Content-Disposition: form-data; name="Title"'+ 
'\r\n'+
'\r\n'+
fileName +
'\r\n'+
'--------------------------d74496d66958873e'+
'\r\n'+
'Content-Disposition: form-data; name="files"; filename="file.pdf"' 
+'\r\n'+
'Content-Type: application/octet-stream'+
'\r\n'+
'\r\n'+
msg.payload+
'\r\n'+
'--------------------------d74496d66958873e--'+
'\r\n';

msg.url = "https://fqdn/v0.1/companies/1782/candidates/1234/attachments";

```

I'm "injecting" this in to a http request node...

This works fine with txt-files, but when trying with PDF, the document gets destroyed.  
msg.payload comes from a file in node delivering the msg.payload as "a single buffer object"

Any one with thoughts or ideas on this?

BR  
Kjell Brandes

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [3 May 2021 16:43 UTC](https://discourse.nodered.org/t/posting-pdf-files-multipart-form-data/42033/2 "2021-05-03T16:43:56Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
