Transfer files from edge

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 ?

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


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,

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?

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 ?


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


Thanks, I forgot about that.
I see this:


This looks correct. I would recommend taking a look at the Blob documentation. What you’re seeing is a Signed URL to download the file you sent as device state.

Thank you,

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

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

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

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?

You may be able to adapt the File Upload Form template 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 API endpoint 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.

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

It cannot be done in the workflow currently, because the file must be submitted to the signed URL as 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 describing how to do this in curl; I would recommend checking those out. You’d invoke this using a Run Executable Node.

ok, I’ll give this a try.

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.

I have a custom edge image so curl is available.

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

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.

Awesome !, that sounds great