mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Use stream when downloading documents
This commit is contained in:
parent
ae6fa5ab9b
commit
10fa256809
@ -38,10 +38,23 @@ class DocumentController extends BaseController
|
|||||||
return redirect($direct_url);
|
return redirect($direct_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$stream = $document->getStream();
|
||||||
|
|
||||||
$response = Response::make($document->getRaw(), 200);
|
if($stream){
|
||||||
$response->header('content-type', $document->type);
|
$headers = [
|
||||||
|
'Content-Type' => $document->type,
|
||||||
|
'Content-Length' => $document->size,
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = Response::stream(function() use ($stream) {
|
||||||
|
fpassthru($stream);
|
||||||
|
}, 200, $headers);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$response = Response::make($document->getRaw(), 200);
|
||||||
|
$response->header('content-type', $document->type);
|
||||||
|
}
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +122,12 @@ class Document extends EntityModel
|
|||||||
return $disk->get($this->path);
|
return $disk->get($this->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getStream(){
|
||||||
|
$disk = $this->getDisk();
|
||||||
|
|
||||||
|
return $disk->readStream($this->path);
|
||||||
|
}
|
||||||
|
|
||||||
public function getRawPreview(){
|
public function getRawPreview(){
|
||||||
$disk = $this->getDisk();
|
$disk = $this->getDisk();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user