get('oneup_flysystem.media_filesystem'); if ($mediaFilesystem->has($path)) { $response = new BinaryFileResponse($mediaFilesystem->getAdapter()->getPathPrefix().DIRECTORY_SEPARATOR.$path); $response->headers->set('Content-Type', $mediaFilesystem->getMimetype($path)); // Create the disposition of the file $disposition = $response->headers->makeDisposition( ResponseHeaderBag::DISPOSITION_ATTACHMENT, basename($path) ); $response->headers->set('Content-Disposition', $disposition); return $response; } throw new FileNotFoundException($path); } }