This works fine with devMode(true)
, but not when false.
I'm calling it as a craft variable {% do craft.mymodule.pdf(entry) %}
public function pdf(Entry $entry)
{
$asset = $entry->asset->one();
$fsPath = Craft::getAlias($asset->getVolume()->fs->path);
$file = $fsPath . '/' . $asset->getPath();
header('Accept-Ranges: bytes');
header('Cache-Control: maxage=1');
header('Content-Length: ' . $asset->size);
header('Content-Transfer-Encoding: binary');
header('Content-Type: ' . $asset->getMimeType());
header('Content-disposition: inline; filename=' . basename($asset->filename));
header('Pragma: public');
readfile($file);
exit;
}
Error message
BTW, nothing in the logs when it fails.