Skip to content
This repository was archived by the owner on Nov 10, 2022. It is now read-only.

Commit 9f766fc

Browse files
committed
Added ability to render a file from storage to the browser
1 parent c84c5a8 commit 9f766fc

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,10 @@ Get the full URL to a file in storage:
128128

129129
```php
130130
Storage::url('user/avatar.jpg');
131+
```
132+
133+
Render a file from storage to the browser:
134+
135+
```php
136+
Storage::render('user/avatar.jpg');
131137
```

src/Dmyers/Storage/Adapter/Base.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,22 @@ abstract public function files($path);
161161
* @return string
162162
*/
163163
abstract public function url($path);
164+
165+
/**
166+
* Render a file from storage to the browser.
167+
*
168+
* @param string $path The path to the file to render.
169+
*
170+
* @return Response
171+
*/
172+
public function render($path)
173+
{
174+
$file = static::get($path);
175+
176+
$mime = static::mime($path);
177+
178+
return \Response::make($file, 200, array(
179+
'Content-Type' => $mime,
180+
));
181+
}
164182
}

0 commit comments

Comments
 (0)