# Uploading file http put request

**URL:** <https://discourse.nodered.org/t/uploading-file-http-put-request/44725>\
**Category:** General\
**Created:** [26 April 2021 07:04 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725 "2021-04-26T07:04:51Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![francodutch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/francodutch/32/38566_2.png) [@francodutch](https://discourse.nodered.org/u/francodutch)\
**Post date:** [26 April 2021 07:04 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/1 "2021-04-26T07:04:51Z")

</div>

Hi everyone I need some help after struggling with a topic I'm not familiar with. I want to upload a jpg to a one off signed url which I receive through mqtt. It needs to be through a PUT method. Does anyone have a working example?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 April 2021 07:23 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/2 "2021-04-26T07:23:48Z")

</div>

The [node-red cookbook](https://cookbook.nodered.org/#http-requests) has some examples to get you heading in the right direction. Give it a go & if you get stuck, pop back with details.

---

<div class="post-metadata">

**Author:** ![francodutch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/francodutch/32/38566_2.png) [@francodutch](https://discourse.nodered.org/u/francodutch)\
**Post date:** [26 April 2021 07:30 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/3 "2021-04-26T07:30:18Z")

</div>

thanks @Steve-Mcl i have seen and imported most of these. Most are http-in and the part I'm stuck on is how to attach a binary file. I'm also not sure if the authentication info that's part of the signed url ("X-Amz-Algorithm" for instance) need to be split off and sent as I dividual headers.id love to avoid having to parse the url that way.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 April 2021 07:35 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/4 "2021-04-26T07:35:08Z")

</div>

> [@francodutch](#):
>
> X-Amz-Algorithm

Your probably going to have to get to grips with the Amazon docs for that. There are no prior posts on this matter. Maybe someone has already approached this and can help?. I have not I'm afraid.

---

<div class="post-metadata">

**Author:** ![francodutch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/francodutch/32/38566_2.png) [@francodutch](https://discourse.nodered.org/u/francodutch)\
**Post date:** [26 April 2021 07:38 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/5 "2021-04-26T07:38:17Z")

</div>

how about the file upload? I suspect that leaving the security info in the url will work - but I need to be able to attach a file.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 April 2021 08:21 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/6 "2021-04-26T08:21:49Z")

</div>

> [@francodutch](#):
>
> how about the file upload?

Have you tried setting payload as described in the help?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/7/b7ad1a51cd1109ab90e77603a420aa2800319ddd.png)

I would guess it needs to be a buffer that contains the image data. (but I dont know the system you are sending it to)

---

<div class="post-metadata">

**Author:** ![francodutch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/francodutch/32/38566_2.png) [@francodutch](https://discourse.nodered.org/u/francodutch)\
**Post date:** [26 April 2021 08:36 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/7 "2021-04-26T08:36:16Z")

</div>

That's where I'm stuck - what does it mean to send something as a buffer and how do you do that...

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 April 2021 09:07 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/8 "2021-04-26T09:07:12Z")

</div>

Where is the `jpg` - in a file? received from mqtt? from another URL?

In other words, how do you load the `jpg` image into node red? Show me.

Also, attach a debug node the node that gets the jpg - what does the payload look like in the debug window?

### PS

As you dont reply to my comment using the reply button at the bottom of my response (and instead you use the general reply button at the bottom of the thread) I have no idea you have responded to me - as i dont get a notification.

---

<div class="post-metadata">

**Author:** ![francodutch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/francodutch/32/38566_2.png) [@francodutch](https://discourse.nodered.org/u/francodutch)\
**Post date:** [26 April 2021 09:36 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/9 "2021-04-26T09:36:55Z")

</div>

Oops thanks for letting me know @Steve-Mcl . Hard to see the difference on my phone. The jpg is on the same raspberry pi that serves nodered. It's a snapshot from a camera created by an external function that's called earlier in the flow and that passes on the filename. So I have access to it but don't know what to do with it to get it to be part of the http put request.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 April 2021 09:42 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/10 "2021-04-26T09:42:54Z")

</div>

Use a `file in` node (set to return a buffer). The msg coming out of the file node will be a binary (Buffer) representing the file.

Question - what is this external function that grabs the image? What kind of camera is it?  
The reason I ask is, there is possibly a solution that doesn't need to write to the file system (all done in memory) - this has the benefit of avoiding unnecessary file write (save the SD) and faster / cleaner solution.

---

<div class="post-metadata">

**Author:** ![francodutch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/francodutch/32/38566_2.png) [@francodutch](https://discourse.nodered.org/u/francodutch)\
**Post date:** [26 April 2021 12:19 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/11 "2021-04-26T12:19:44Z")

</div>

It's an esp32. I could do the processing on the esp32 but I prefer to use esphome / home assistant to manage all devices.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 April 2021 12:22 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/12 "2021-04-26T12:22:32Z")

</div>

so how do you transmit the image to node-red? what node does the image arrive in?

---

<div class="post-metadata">

**Author:** ![francodutch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/francodutch/32/38566_2.png) [@francodutch](https://discourse.nodered.org/u/francodutch)\
**Post date:** [26 April 2021 12:36 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/13 "2021-04-26T12:36:40Z")

</div>

The home assistant automation platform runs on the same server and the file system is accessible by both it and nr. I send a request with nr to ha to store a snapshot - with the rename as parameter so I can find it later on.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 April 2021 12:38 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/14 "2021-04-26T12:38:39Z")

</div>

ok, fair enough, not how i would approach it but each to their own.

So have you managed to use a file in node and load the file into a msg payload?

---

<div class="post-metadata">

**Author:** ![francodutch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/francodutch/32/38566_2.png) [@francodutch](https://discourse.nodered.org/u/francodutch)\
**Post date:** [26 April 2021 12:41 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/15 "2021-04-26T12:41:47Z")

</div>

Not yet - when I'm back home

---

<div class="post-metadata">

**Author:** ![francodutch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/francodutch/32/38566_2.png) [@francodutch](https://discourse.nodered.org/u/francodutch)\
**Post date:** [26 April 2021 12:44 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/16 "2021-04-26T12:44:36Z")

</div>

And no not the ideal setup if viewed in isolation but it's one of many devices and I want to minimise logic directly on the device. Thanks for the help I will post the result for others once I have it working.

---

<div class="post-metadata">

**Author:** ![francodutch](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/francodutch/32/38566_2.png) [@francodutch](https://discourse.nodered.org/u/francodutch)\
**Post date:** [26 April 2021 22:39 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/17 "2021-04-26T22:39:42Z")

</div>

It works w `http out` node. `File in` node creates a buffer from the local file and sets it as payload. No need to parse the URL for headers I just leave them in `msg.url` (filename as well), only a header w image type jpeg. Thanks for the help!

---

<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:** [25 June 2021 22:40 UTC](https://discourse.nodered.org/t/uploading-file-http-put-request/44725/18 "2021-06-25T22:40:07Z")

</div>

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