header('Pragma: no-cache');
header('cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
//TODO add context to login
if(MMUsers::isAnonymous(MMUsers::getCurrentUserId()))
{
    $host = eZSys::serverURL();
    $siteIni = eZINI::instance( 'site.ini' );
    $loginUrl = preg_replace('#^https?//[^/]+#', '', $siteIni->variable('SiteSettings', 'LoginPage'));
    $context = $host . '/esibuild/download/' . $nodeID;
    header( 'Location: ' . $loginUrl . '?context='.urlencode($context) );
    eZExecution::cleanExit();
}

//test if application allow download
if(!SecurityTool::getFileApplicationCanRead($node))
{
    header('HTTP/1.1 403 Forbidden');
    echo "<h1>Forbidden access</h1>\n";
    eZExecution::cleanExit();
}

if($node)
{
    /* @type $dataMap eZContentObjectAttribute[] */
    $dataMap = $node->dataMap();

    if(array_key_exists('file', $dataMap))
    {
        /* @type $content eZImageAliasHandler */
        $file    = $dataMap['file'];