Skip to content
This repository has been archived by the owner on Feb 5, 2019. It is now read-only.

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Joan Fabrégat committed Mar 4, 2018
1 parent adcb306 commit e85d0e0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codeinchq/lib-psr7responses",
"version": "1.1.9",
"version": "1.1.10",
"description": "A collection of PSR-7 responses",
"homepage": "https://github.com/codeinchq/lib-psr7responses",
"type": "library",
Expand Down
14 changes: 13 additions & 1 deletion src/FileResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
* @author Joan Fabrégat <[email protected]>
*/
class FileResponse extends StreamResponse {
public const DEFAULT_MIME_TYPE = 'application/octet-stream';

/**
* FileResponse constructor.
*
Expand Down Expand Up @@ -61,9 +63,14 @@ public function __construct(string $filePath, ?string $fileName = null, ?string
);
}

// looking up the mime type using
if (!$mimeType && ($dotPost = strrpos(basename($fileName), ".")) !== false) {
$mimeType = Mime::getMimeFromExtension(substr(basename($fileName), $dotPost + 1));
}

parent::__construct(
$f,
$mimeType ?? Mime::getMimeFromExtension($filePath),
$mimeType ?? self::DEFAULT_MIME_TYPE,
filesize($filePath) ?: null,
$fileName ?? basename($filePath),
$asAttachment,
Expand All @@ -73,4 +80,9 @@ public function __construct(string $filePath, ?string $fileName = null, ?string
$reason
);
}

private function getFileMimeType(string $fileName, ?string $mimeType):string
{

}
}

0 comments on commit e85d0e0

Please sign in to comment.