# Transfer files from edge

**URL:** <https://forums.losant.com/t/transfer-files-from-edge/3951>\
**Category:** Help\
**Tags:** edge\
**Created:** [July 23, 2021, 5:16pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951 "2021-07-23T17:16:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [July 23, 2021, 5:16pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/1 "2021-07-23T17:16:38Z")

</div>

I have a bunch of png files generated on a device connected to an edge compute device.  
Can the the Losant agent transfer those images to images available in the experience/files folders ?

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [July 23, 2021, 5:18pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/3 "2021-07-23T17:18:34Z")

</div>

I tried sending those as device state blobs to an attribute, but couldn’t get that to work.

---

<div class="post-metadata">

**Author:** ![Heath](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/heath/32/3036_2.png) [@Heath](https://forums.losant.com/u/Heath)\
**Post date:** [July 23, 2021, 6:07pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/4 "2021-07-23T18:07:27Z")

</div>

@Lars_Andersson,

> I tried sending those as device state blobs to an attribute, but couldn’t get that to work.

Can you tell me a bit more about what didn’t work? Were you getting an error? If so, could you send a screenshot of that error?

Typically to send images over MQTT you will need to base64 encode the image, then report that base64 encoded string as a blob attribute. Is this what you tried?

Thank you,  
Heath

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [July 23, 2021, 6:22pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/6 "2021-07-23T18:22:41Z")

</div>

I didn’t get any error, just that the workflow eventually timed out.  
Just realized that the images are 364k, so is that why nothing shows in the debug console?

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [July 23, 2021, 6:46pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/8 "2021-07-23T18:46:52Z")

</div>

Tried with a smaller image using {{{ encodeBase64 data.resultsCut.value}}} in the Device state node.  
The result path’s payload tells me “sucess: true”.  
How can I best verify that some got added to the state data ?

---

<div class="post-metadata">

**Author:** ![Heath](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/heath/32/3036_2.png) [@Heath](https://forums.losant.com/u/Heath)\
**Post date:** [July 23, 2021, 7:03pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/9 "2021-07-23T19:03:19Z")

</div>

@Lars_Andersson,

Assuming that your device is connected to Losant, you can go to the device in Losant and look at its previous device state reports.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/e/ef2ec4a81bb39325363a480772fc23252aa93db1.png)

Thanks,  
Heath

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [July 23, 2021, 7:11pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/10 "2021-07-23T19:11:05Z")

</div>

Thanks, I forgot about that.  
I see this:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/8/8225ec37a95e2d3f6d534b8efdf683d53985d702.png)

---

<div class="post-metadata">

**Author:** ![Heath](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/heath/32/3036_2.png) [@Heath](https://forums.losant.com/u/Heath)\
**Post date:** [July 23, 2021, 8:32pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/11 "2021-07-23T20:32:10Z")

</div>

@Lars_Andersson,

This looks correct. I would recommend taking a look at the [Blob documentation](https://docs.losant.com/devices/blobs/#blob-usage). What you’re seeing is a [Signed URL](https://docs.losant.com/devices/blobs/#signed-urls) to download the file you sent as device state.

Thank you,  
Heath

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [July 23, 2021, 9:03pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/12 "2021-07-23T21:03:28Z")

</div>

Ok. Shouldn’t I be able to click that link to download it?

When I do that it says is a non supported format.

---

<div class="post-metadata">

**Author:** ![Heath](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/heath/32/3036_2.png) [@Heath](https://forums.losant.com/u/Heath)\
**Post date:** [July 23, 2021, 9:06pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/13 "2021-07-23T21:06:42Z")

</div>

Hey @Lars_Andersson,

I followed up with you in a DM to get that link. We’ll come back to this thread once we have this resolved!

Thank you  
Heath

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [July 26, 2021, 1:00pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/14 "2021-07-26T13:00:53Z")

</div>

I get this error in the workflow: message":  
“Payload size cannot exceed 262144”

And I realize now that most of them probably are bigger, so I need an alternate path.  
What do you recommend to get the image files from the edge node to the Losant application?

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [July 26, 2021, 2:23pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/15 "2021-07-26T14:23:39Z")

</div>

You may be able to adapt the [File Upload Form template](https://app.losant.com/applications/recent/template-library?templateId=606355f6fc60290006ae3063) for your use case. That template demonstrates how to upload a file from an experience page, but the principle applies here as well. You could extract the workflow from that template and modify it for your use case.

The template works as follows:

1. On start of the upload process, first make a request to the [files.post API endpoint](https://docs.losant.com/rest-api/files/#post) with some meta information about the file.
2. That replies with a signed URL that can be used in the next step.
3. The client (a web browser in the experience case, and your edge device in your case) then submits a POST request to the URL returned previously and submits the file as form data.

In your case, you’d need to first something outside of the edge agent to make the HTTP request that actually posts the file to the signed URL, probably using a [Run Executable Node](https://docs.losant.com/workflows/data/run-executable/).

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [July 26, 2021, 3:06pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/17 "2021-07-26T15:06:52Z")

</div>

ok. So an edge workflow couldn’t make that HTTP request?  
The imager file is reachable in a common data directory.

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [July 26, 2021, 3:20pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/19 "2021-07-26T15:20:40Z")

</div>

It cannot be done in the workflow currently, because the file must be submitted to the signed URL as [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData), which is not supported in the HTTP Node. (I’ve just made a feature request to add that functionality.)

There are a [number of articles](https://www.google.com/search?q=curl+formdata+file) describing how to do this in [curl](https://curl.se/); I would recommend checking those out. You’d invoke this using a Run Executable Node.

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [July 26, 2021, 3:24pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/20 "2021-07-26T15:24:20Z")

</div>

ok, I’ll give this a try.

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [July 26, 2021, 4:10pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/21 "2021-07-26T16:10:59Z")

</div>

One quick thing to note: curl is not available in the Alpine version of the edge agent, so if that’s the version you’re using, we’ll need to come up with a different workaround.

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [July 26, 2021, 4:17pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/22 "2021-07-26T16:17:35Z")

</div>

I have a custom edge image so curl is available.

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [July 26, 2021, 4:50pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/23 "2021-07-26T16:50:18Z")

</div>

So step 1 and 2 above could be done from the edge agents workflow?

---

<div class="post-metadata">

**Author:** ![Dylan\_Schuster](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/dylan_schuster/32/2850_2.png) [@Dylan\_Schuster](https://forums.losant.com/u/Dylan_Schuster)\
**Post date:** [July 26, 2021, 5:54pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/24 "2021-07-26T17:54:49Z")

</div>

Exactly. I’m actually working on an implementation for this right now; I’m not sure I’ll get it done today but I will post my workflow here once I have something I can share.

---

<div class="post-metadata">

**Author:** ![Lars\_Andersson](https://avatars.discourse-cdn.com/v4/letter/l/f05b48/32.png) [@Lars\_Andersson](https://forums.losant.com/u/Lars_Andersson)\
**Post date:** [July 26, 2021, 6:00pm UTC](https://forums.losant.com/t/transfer-files-from-edge/3951/25 "2021-07-26T18:00:04Z")

</div>

Awesome !, that sounds great

[Next page](https://forums.losant.com/t/transfer-files-from-edge/3951.md?page=2)
