Skip to content


DownloadFile Extension

DownloadFile is a configuration extension for Foliant which downloads external files to use in your project.

It also resolves !download YAML tag in the project config and inside XML-tags parameters.


$ pip install foliantcontrib.downloadfile


To configure DownloadFile add the following section to your foliant.yml file:

    fail_fast: true
    ignore_ssl_errors: false
        - url:  # required
          save_to: images/img1.png
          login: john
          password: qwerty123
        - ...
When true, build will be stopped if any file can't be downloaded. If false ­— unavailable files will be just skipped. Doesn't affect !download tag, this one will always break the build on errors. Default: true.
Switch to true to skip SSL certificate check. Default: false.
list of files to download. Each file is represented by a dictionary with the following fields:
(requried) URL to the file which should be downloaded.
path where the downloaded file should be saved, relative to the project root. If not supplied, file will be saved in the project root with the name from url.
login for basic authentication.
password for basic authentication.

Warning: don't store plain text passwords in foliant.yml. Use environment variables.

!download YAML tag

Another way to use DownloadFile is by specifying !download YAML tag. This is the quickest and the simplest way, but it comes with a few disadvantages.

Insert the !download tag, followed by file URL, in any place in foliant.yml or tag parameters, where file path is expected:

    - swaggerdoc:
        spec_path: !download
        mode: widdershins
Generated template:

<template engine="jinja2" ext_context="!download">

The downloaded file will be saved in the .downloadfilecache directory under a hashed name, and the !download tag will be replaced by absolute path to this file.

The cons of this method are that you can't change the saved file path nor other parameters. Also if you reference the same file twice with !download tag, it will be downloaded two times.

Back to top