add 'inline' route to allow embedding uploads

This change adds an 'inline' route to uploads which sets the
'Content-Disposition' HTTP header to 'inline'. This allows modules to
embed and display uploads in an HTML 'embed' element.
This commit is contained in:
Hendrik Hagendorn
2023-05-21 14:16:48 +02:00
parent 9429728281
commit d3661038ac
3 changed files with 19 additions and 1 deletions

View File

@ -34,6 +34,22 @@ class Uploads extends Controller
return $this->streamMedia($media);
}
public function inline($id)
{
try {
$media = Media::find($id);
} catch (\Exception $e) {
return response(null, 204);
}
// Get file path
if (!$this->getMediaPathOnStorage($media)) {
return response(null, 204);
}
return $this->streamMedia($media, 'inline');
}
/**
* Get the specified resource.
*