use BookStack\Interfaces\Loggable;
use BookStack\HasCreatorAndUpdater;
use BookStack\Model;
+use finfo;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Exceptions\HttpResponseException;
]);
}
+ /**
+ * Create a file download response that provides the file with a content-type
+ * correct for the file, in a way so the browser can show the content in browser.
+ */
+ protected function inlineDownloadResponse(string $content, string $fileName): Response
+ {
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
+ $mime = $finfo->buffer($content) ?: 'application/octet-stream';
+ return response()->make($content, 200, [
+ 'Content-Type' => $mime,
+ 'Content-Disposition' => 'inline; filename="' . $fileName . '"'
+ ]);
+ }
+
/**
* Show a positive, successful notification to the user on next view load.
*/
*/
protected function getImageValidationRules(): string
{
- return 'image_extension|no_double_extension|mimes:jpeg,png,gif,webp';
+ return 'image_extension|mimes:jpeg,png,gif,webp';
}
}