|
|
@@ -37,17 +37,26 @@ final class DownloadRequestDataProvider implements ItemDataProviderInterface, Re
|
|
|
if ($file->getStatus() !== FileStatusEnum::READY()->getValue()) {
|
|
|
throw new \RuntimeException("File " . $id . " has " . $file->getStatus() . " status; abort.");
|
|
|
}
|
|
|
+ if ($file->getHost() === 'api') {
|
|
|
+ throw new \RuntimeException('Incorrect host for file ' . $id . '');
|
|
|
+ }
|
|
|
|
|
|
$content = $this->storage->read($file);
|
|
|
|
|
|
// @see https://symfony.com/doc/current/components/http_foundation.html#serving-files
|
|
|
$response = new Response($content);
|
|
|
|
|
|
- $disposition = HeaderUtils::makeDisposition(
|
|
|
- HeaderUtils::DISPOSITION_ATTACHMENT,
|
|
|
- $file->getName()
|
|
|
+ $response->headers->set('Charset', 'UTF-8');
|
|
|
+ $response->headers->set('Access-Control-Expose-Headers', 'Content-Disposition');
|
|
|
+
|
|
|
+ if (!empty($file->getMimeType())) {
|
|
|
+ $response->headers->set('Content-Type', $file->getMimeType());
|
|
|
+ }
|
|
|
+
|
|
|
+ $response->headers->set(
|
|
|
+ 'Content-Disposition',
|
|
|
+ HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, $file->getName())
|
|
|
);
|
|
|
- $response->headers->set('Content-Disposition', $disposition);
|
|
|
|
|
|
return $response;
|
|
|
}
|