# HTTP Post Image image

**URL:** <https://discourse.nodered.org/t/http-post-image-image/32669>\
**Category:** General\
**Created:** [10 September 2020 02:01 UTC](https://discourse.nodered.org/t/http-post-image-image/32669 "2020-09-10T02:01:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kceleslie](https://avatars.discourse-cdn.com/v4/letter/k/d9b06d/32.png) [@kceleslie](https://discourse.nodered.org/u/kceleslie)\
**Post date:** [10 September 2020 02:01 UTC](https://discourse.nodered.org/t/http-post-image-image/32669/1 "2020-09-10T02:01:03Z")

</div>

I'm trying to create a flow that will upload an image to pushbullet. The pushbullet APi has 2 parts for uploading an image. I have the first part working, but cannot seem to get the image upload to work correctly. I've captured some wireshark traffic of the upload and the upload size is almost double what the actual file size is. I've captured a valid one with curl and the it looks identical except for the actual image content.

I'm using the file in to read the image and pass it along to an http request node. When i run it with an actual pushbullet URL i get the expected response but when i go to view the image i get an error, somethig along the lines that the image was invalid. Any suggestions?

```auto
[{"id":"e43ebba6.7a0408","type":"http request","z":"384402ce.39cd6e","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"http://192.168.20.53:8000","tls":"","persist":false,"proxy":"","authType":"","x":710,"y":260,"wires":[["b08393e2.bc827"]]}]

```

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [10 September 2020 07:36 UTC](https://discourse.nodered.org/t/http-post-image-image/32669/2 "2020-09-10T07:36:52Z")

</div>

Hi, I would guess that at some point you are not handling the image as a binary buffer. At some point pushbullet will need it in some format (maybe base64 encoded? You'll have to read docs).

---

<div class="post-metadata">

**Author:** ![kceleslie](https://avatars.discourse-cdn.com/v4/letter/k/d9b06d/32.png) [@kceleslie](https://discourse.nodered.org/u/kceleslie)\
**Post date:** [11 September 2020 01:26 UTC](https://discourse.nodered.org/t/http-post-image-image/32669/3 "2020-09-11T01:26:37Z")

</div>

I think the problem is within my function. The file in node reads the file as a binary object then passes it to this function. This function then converts it to a string. The pushbullet APi doesnt specify what format it must be in, only that it must be in a multipart/form-data.

```auto
var image = msg.payload
msg.headers = {
    "Content-Type": "multipart/form-data; boundary=------------------------d74496d66958873e"
}

msg.payload = '--------------------------d74496d66958873e\r\n'+
'Content-Disposition: form-data; name="file"; filename="pizza.jpg"\r\n'+
'Content-Type: image/jpeg\r\n'+
'\r\n'+
image+'\r\n'+
'--------------------------d74496d66958873e--\r\n';

return msg;

```

---

<div class="post-metadata">

**Author:** ![kceleslie](https://avatars.discourse-cdn.com/v4/letter/k/d9b06d/32.png) [@kceleslie](https://discourse.nodered.org/u/kceleslie)\
**Post date:** [12 September 2020 00:58 UTC](https://discourse.nodered.org/t/http-post-image-image/32669/4 "2020-09-12T00:58:49Z")

</div>

I was able to get it working by using these from the http request node

```auto
{
    "KEY": {
        "value": FILE_CONTENTS,
        "options": {
            "filename": "FILENAME"
        }
    }
}

```

---

<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:** [26 September 2020 00:58 UTC](https://discourse.nodered.org/t/http-post-image-image/32669/5 "2020-09-26T00:58:58Z")

</div>

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