Skip to main content
Version: Next

File Transfer Service

The tedge-agent hosts a binary repository for child devices and other plugins/extensions to exchange binary files between them. This repository is meant to be used as a temporary storage for exchanging files, and not for storing items permanently, as the storage on thin-edge.io devices are typically very limited.

Files can be uploaded, downloaded and deleted from this repository via the following HTTP endpoints:

TypeMethodEndpoint
UploadPUThttp://{fts-address}:8000/te/v1/files/{path}/{to}/{resource}
DownloadGEThttp://{fts-address}:8000/te/v1/files/{path}/{to}/{resource}
DeleteDELETEhttp://{fts-address}:8000/te/v1/files/{path}/{to}/{resource}

The fts-address is derived from http.client.host config setting with a default value of 127.0.0.1.

The files uploaded to this repository are stored at /var/tedge/file-transfer directory. The {path}/{to}/{resource} specified in the URL is replicated under this directory.

For example, a file uploaded to http://{fts-address}/te/v1/files/config_update/mosquitto/mosquitto.conf is stored at /var/tedge/file-transfer/config_update/mosquitto/mosquitto.conf.

An existing file at a given path is replaced on subsequent uploads using the same URL path. Unique paths must be used in the URL path to avoid such overwrites.

All uploaded files are preserved until they are explicitly deleted with the DELETE API. To avoid exhaustion of storage space on the thin-edge.io device, users must be diligent to delete any stored files as soon as their purpose is served.

A request is rejected with 404 Not Found if its path resolves outside /var/tedge/file-transfer, whether through .. components or through a symlink inside that directory. A dangling symlink, or a symlink loop, is rejected in the same way.

The only exception is the agent's file cache (/var/tedge/cache). The agent serves some files, such as the configuration file of a config_update operation, through a symlink from /var/tedge/file-transfer into its cache. Those files can be downloaded with GET, but not replaced with PUT.

A DELETE request removes a symlink itself, and never the file or directory it points to.

HTTPS and authenticated access​

By default, the service is unauthenticated and does not support HTTPS connections. HTTPS can be enabled by setting http.cert_path and http.key_path. If the certificates are configured, the agent will automatically host the service via HTTPS, and redirect any HTTP requests to the equivalent HTTPS URL. If HTTPS is enabled, the configured certificate should be installed in the OS trust store for any connected agents in order for them to trust the connection to the mapper.

Once HTTPS is enabled for the file-transfer service, certificate-based authentication can also be enabled. The directory containing the certificates that the agent will trust can be configured using http.ca_path, and the mapper as well as the child device agents can be configured to use a trusted certificate using the http.client.auth.cert_file and http.client.auth.key_file settings.

Using tedge http​

tedge http can be used to access the file transfer service from any child devices, provided proper configuration.

TypeCommand
Uploadtedge http put /te/v1/files/{path}/{to}/{resource} --file /{path}/{to}/{file}
Downloadtedge http get /te/v1/files/{path}/{to}/{resource} >/{path}/{to}/{file}
Deletetedge http delete /te/v1/files/{path}/{to}/{resource}