HTTP Post Image image

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?

[{"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"]]}]

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).

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.

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;

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

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

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