Transfer file to IOT


I need to transfer an application data file to the raspberry pi, may be a couple times a day. The file size is around 20mb. I am considering the following options:

  • break down the file in small chunks and transfer the data using MQTT
  • use HTTP to post the file to the pi
  • does balena provide any file transfer services that I can use

I am new to IOT, which way is the prefer way? I can see with the MQTT approach, i need to resemble the file from the MQTT messages and the HTTP approach I need to run a http server on the pi.


Hi Patrick,

A chunk of 20mb for a couple of times a day should not be a problem for a RPi device.

Probably the easiest way to transfer a file to the device is to use our CLI with the balena tunnel command as described in the bottom of this post:

In this way you won’t have to run additional services in your container, but you can directly copy/scp the contents to the desired location. Will such a solution work for you?


Hi Zahari,

Thanks for the suggestion. I tried that and it works! Now, I have another question, should I upload the data file directly to

/var/lib/docker/volumes/<APP_ID + volume>-data/_data

so that the container can access the file? I checked the balena doc and it stated it doesn’t support docker volume bind.


@pli yes you can put the file in that location if you’d like to access it from a container. You’re right in that you can’t bind other directories on the host OS but you can add files to named volumes in the way you’re proposing.

Thanks for the reply. I have two questions about using the balena tunneling

balena login --credentials --email --password

balena tunnel <device’s uuid> -p 22222:4321
[Info] Tunnel to <device’s uuid>
? Select a device
[Info] - tunnelling localhost:4321 to <device’s uuid>
[Info] Waiting for connections…

First question is even if I specify the device’s uuid in the balena tunnel command, it still prompts me to confirm the device from a list of my devices. Is there a way to disable the prompt? If not, I can do “echo | balena tunnel …” to automate the selection.

Second question is the balena tunnel command is hung at “Waiting for connections…”. Any idea why it is hanging? I am running the development os on the pi.


I have created a GitHub issue for the fact that balena tunnel offers a selection menu despite being given a UUID, as it looks like a bug:

When you say it is hanging at “Waiting for connections”, do you mean it doesn’t work then? Or it works, but still hangs? Could you confirm the version of your CLI (balena version), and your computer’s operating system? (Windows, macOS, Linux)

@pli, to add to my previous message, perhaps what you meant by “hanging” is the expected behaviour, in case it behaves as follows:

On a command terminal on my laptop:

$ ./bin/balena tunnel b1878c6 -p 22222:4321
[Info]    Tunnel to b1878c6
? Select a device lucky-star (<short uuid>)
[Info]     - tunnelling localhost:4321 to <uuid>:22222
[Info]    Waiting for connections...

So it “hangs” as above. Then, on another command terminal, also on my laptop:

$ ssh -p 4321 root@
Warning: Permanently added '[]:4321' (RSA) to the list of known hosts.

At this point, a log message is printed back on the first terminal what was “hanging there”:

[Info]    Waiting for connections...
[Logs] => ===>

So the “hanging” terminal serves two purposes: it is where log / error messages are printed, and it serves as a “foreground process” (or a “visible process”) responsible for keeping the tunnel open. An alternative would be a “detached” or “background” process, that created a running service behind the scenes and logged messages to a file. That’s not how it’s currently implemented, but if could raise it as a feature request in the balena-cli repo if you think there is a use case for it.