$filesystem =
$this->container->
get('shopware.filesystem.private'
);
$path =
$this->container->
get(Shopware_Components_Config::
class)->
offsetGet('esdKey'
) . '/' .
$this->
Request()->
getParam('filename'
);
if ($filesystem->
has($path) === false
) { $this->
Front()->
Plugins()->
Json()->
setRenderer();
$this->
View()->
assign(['message' => 'File not found', 'success' => false
]);
return;
} $meta =
$filesystem->
getMetadata($path);
$mimeType =
$filesystem->
getMimetype($path) ?: 'application/octet-stream';
@
set_time_limit(0
);
$this->
Front()->
Plugins()->
ViewRenderer()->
setNoRender();
$response =
$this->
Response();
$response->headers->
set('content-type',
$mimeType);
$response->headers->
set('content-disposition',
sprintf('attachment; filename="%s"',
basename($path)));
$response->headers->
set('content-length',
$meta['size'
]);
$response->headers->
set('content-transfer-encoding', 'binary'
);
$response->
sendHeaders();