DEV Community

Cover image for MQTT File Uploader: Automate Your File Transfers with MQTT and .NET
Volkan Alkılıç
Volkan Alkılıç

Posted on


MQTT File Uploader: Automate Your File Transfers with MQTT and .NET


As an IoT developer, you may need to transfer files from your devices or servers to a remote location for analysis, storage, or sharing. One popular protocol for this purpose is the Message Queuing Telemetry Transport (MQTT), which is lightweight, efficient, and reliable. However, MQTT is primarily designed for messaging and may not provide native support for file transfer. Therefore, you need to develop a custom application that converts your files into MQTT messages and publishes them to a broker.

To help you with this task, I have created the MQTT File Uploader, a .NET Core console application that monitors a list of directories and uploads any created, changed, or deleted files to an MQTT broker. The program supports various configuration options, such as the file types, the broker settings, the compression, and the encryption.

Source Code

You can access code from Github Repository

Source Code


Here are the main features of the MQTT File Uploader:

  • Supports multiple directories to monitor.
  • Supports multiple file types to upload.
  • Supports optional compression of the file contents.
  • Supports optional encryption of the MQTT communication.
  • Supports various MQTT brokers, such as Mosquitto, HiveMQ, and AWS IoT.
  • Supports various MQTT protocol versions, such as 3.1.1, 5.0, and 5.0 enhanced authentication.
  • Supports various event types, such as created, changed, and deleted files.

Use Case

The MQTT File Uploader is useful in many scenarios, such as:

  • Uploading sensor data from embedded devices to cloud services for analysis and visualization.
  • Uploading log files from servers to remote storages for backup and sharing.
  • Uploading media files from cameras to multimedia servers for streaming and processing.
  • Uploading documents from scanners to document management systems for archiving and indexing.
  • Uploading firmware files from developers to OTA servers for updates and testing.


Here are the steps to use the MQTT File Uploader:

  1. Install .NET Core Runtime or SDK on your device or server.
  2. Download the MQTT File Uploader from the GitHub repository or build it from the source code.
  3. Edit configuration file in TOML format and specify the directories to monitor, the file types to upload, the broker settings, and other options.
  4. Run the MQTT File Uploader.
  5. Create, change, or delete files in the monitored directories and observe the upload status in the console.

Here is an example of a configuration file for the MQTT File Uploader:

directoryPaths = ["/path/to/directory1", "/path/to/directory2"]
includeSubdirectories = true
fileTypes = ["txt", "csv", "pdf"]
brokerHostname = ""
brokerPort = 8883
brokerUsername = "username"
brokerPassword = "password"
topic = "uploads"
protocolVersion = 5
compress = true
sslEnabled = true
sslCertificatePath = "/path/to/certificate.pem"
createdEventEnabled = true
changedEventEnabled = true
deletedEventEnabled = true

Enter fullscreen mode Exit fullscreen mode


The MQTT File Uploader is open-source software released under the MIT License. You can download it, use it, modify it, and distribute it freely, as long as you preserve the copyright notice and the license terms. You can also contribute to the MQTT File Uploader by reporting issues, suggesting features, submitting pull requests, or giving feedback. Your contribution can help improve the MQTT File Uploader and make it more useful for the IoT community.

Top comments (0)