Header Background

Extra Files

Croit offers a simple file server mechanism for serving files to your croit nodes. Our API has two endpoints for this purpose: one unauthenticated and one authenticated using croit user credentials.

Unauthenticated Endpoint extra-files

Place files in the /config/extra-files directory inside the Docker container (you may need to create this directory). These files can be accessed via the API endpoint api/extra-files/path/to/file.

Example:

  1. Create a file on the management node:

    mkdir /config/extra-files
    echo "test" > /config/extra-files/example.txt
    
  2. Load this file on a croit node:

    CROIT_API=$(cat /proc/cmdline | sed 's/.*croit-api=\([^ ]*\) .*/\1/')
    unset http_proxy
    curl http://$CROIT_API/api/extra-files/example.txt > example.txt
    

By default, croit nodes use apt-cacher-ng on the management node as an HTTP proxy to cache OS packages. This proxy needs to be bypassed for downloading extra files, which is why the unset http_proxy command is necessary.

Authenticated Endpoint extra-files-secure

Place files in the /config/extra-files-secure directory inside the Docker container (you may need to create this directory). These files are accessible via the authenticated API endpoint api/extra-files-secure/path/to/file.

Example:

  1. Create a file on the management node:

    mkdir /config/extra-files-secure
    echo "test" > /config/extra-files-secure/example.txt
    
  2. Create a user with the Secure folder role under Croit > User management.

  3. Load this file on a croit node:

    CROIT_API=$(cat /proc/cmdline | sed 's/.*croit-api=\([^ ]*\) .*/\1/')
    unset http_proxy
    curl --user readuser:password http://$CROIT_API/api/extra-files-secure/example.txt > example.txt
    

This setup ensures secure access to files with user authentication.