Skip to content

Commit

Permalink
Fix on file get
Browse files Browse the repository at this point in the history
  • Loading branch information
killua-eu committed Jan 17, 2024
1 parent 9afba1e commit 43301ed
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions glued/Controllers/ServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -877,14 +877,13 @@ public function links_r1(Request $request, Response $response, array $args = [])

if (file_exists($file)) {
$mime = mime_content_type($file);
$fileStream = fopen($file, 'rb');
$stream = (new Psr17Factory())->createStreamFromResource($fileStream);

$response = $response
->withHeader('Content-Type', $mime)
->withHeader('Content-Disposition', "attachment;filename=\"{$res['obj']}.{$mime}\"")
->withHeader('Content-Length', filesize($file));
$response->getBody()->write($stream->getContents());
$fileStream = fopen($file, 'rb');
$stream = (new Psr17Factory())->createStreamFromResource($fileStream);
$response = $response->withBody($stream);
return $response;
} else { $data['status'] = 'Not found'; return $response->withJson($data)->withStatus(404); }
}
Expand Down

0 comments on commit 43301ed

Please sign in to comment.