<?php

$app->get('/download/{id}', function ($request, $response, $args) {
    $this->logger->info("Загрузка файла");

    $fileModel=$this->filesGW->getFile($args['id']);

    //XSendFile
    $path=Helper::getPathForFile($this->settings['uploadFolder'],$fileModel);
    if (file_exists($path)) {
        $response = $response->withHeader('X-SendFile', realpath($path));
        $response = $response->withHeader('Content-Type','application/octet-stream');
        $response = $response->withHeader('Content-Disposition','attachment; filename=' . basename($path));


    }

    return $response;
})->setName('download');