protected function addDownload(\Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface $item) { $fs = $this->getContext()->getFilesystemManager()->get('fs-secure'); $response = $this->getView()->response(); $value = (string) $item->getValue(); if ($fs->has($value)) { $name = $item->getName(); if (pathinfo($name, PATHINFO_EXTENSION) == null && ($ext = pathinfo($value, PATHINFO_EXTENSION)) != null) { $name .= '.' . $ext; } $response->withHeader('Content-Description', 'File Transfer'); $response->withHeader('Content-Type', 'application/octet-stream'); $response->withHeader('Content-Disposition', 'attachment; filename="' . $name . '"'); $response->withHeader('Content-Length', $fs->size($value)); $response->withHeader('Cache-Control', 'must-revalidate'); $response->withHeader('Pragma', 'private'); $response->withHeader('Expires', 0); $response->withBody($response->createStream($fs->reads($value))); } elseif (filter_var($value, FILTER_VALIDATE_URL) !== false) { $response->withHeader('Location', $value); $response->withStatus(303); } else { $response->withStatus(404); } }