本文整理汇总了PHP中Illuminate\Filesystem\Filesystem::mimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem::mimeType方法的具体用法?PHP Filesystem::mimeType怎么用?PHP Filesystem::mimeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Filesystem\Filesystem
的用法示例。
在下文中一共展示了Filesystem::mimeType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFonts
/**
* Return font resources.
*
* @return Illuminate\Http\Response
*/
public function getFonts($font)
{
$fs = new Filesystem();
$fontPath = __DIR__ . '/Assets/font/' . $font;
$mime = $fs->mimeType($fontPath);
$content = $fs->get($fontPath);
$response = response($content, 200, ['Content-Type' => $mime]);
return $this->cacheResponse($response);
}
示例2: getIndex
public function getIndex($id)
{
$user_id = \Hashids::decode($id);
if (!count($user_id)) {
return abort('404');
}
try {
$email = \App\User::findOrFail($user_id[0])->email;
} catch (\App\Exceptions\Exception $e) {
return abort(404);
}
$path = storage_path() . '\\profiles\\' . $email . '\\avatar\\avatar.jpg';
$img = new Filesystem();
try {
$imgReal = $img->get($path);
$headers = array('Content-Type' => $img->mimeType($path));
} catch (\Illuminate\Contracts\Filesystem\FileNotFoundException $exception) {
$imgReal = $img->get(storage_path() . '/profiles/default.jpg');
$headers = array('Content-Type' => $img->mimeType(storage_path() . '/profiles/default.jpg'));
}
return Response::make($imgReal, 200, $headers);
}
示例3: sound
/**
* sound.
*
* @param \Illuminate\Filesystem\Filesystem $filesystem
* @param \Illuminate\Http\Request $request
* @param string $file
*
* @return \Illuminate\Http\Response
*/
public function sound(Filesystem $filesystem, Request $request, $file)
{
$filename = __DIR__ . '/../../../resources/elfinder/sounds/' . $file;
$mimeType = $filesystem->mimeType($filename);
$lastModified = $filesystem->lastModified($filename);
$eTag = sha1_file($filename);
$headers = ['content-type' => $mimeType, 'last-modified' => date('D, d M Y H:i:s ', $lastModified) . 'GMT'];
if (@strtotime($request->server('HTTP_IF_MODIFIED_SINCE')) === $lastModified || trim($request->server('HTTP_IF_NONE_MATCH'), '"') === $eTag) {
$response = $this->responseFactory->make(null, 304, $headers);
} else {
$response = $this->responseFactory->stream(function () use($filename) {
$out = fopen('php://output', 'wb');
$file = fopen($filename, 'rb');
stream_copy_to_stream($file, $out, filesize($filename));
fclose($out);
fclose($file);
}, 200, $headers);
}
return $response->setEtag($eTag);
}
示例4: mimeType
/**
* Get the mime-type of a given file.
*
* @param string $path
* @return string|false
* @static
*/
public static function mimeType($path)
{
return \Illuminate\Filesystem\Filesystem::mimeType($path);
}
示例5: asset
/**
* Gets an asset.
*
* @param string $encPath
* @param string $contentType
*
* @return Provides the valid
*/
public function asset($encPath, $contentType, Filesystem $fileSystem)
{
try {
$path = CryptoServiceFacade::url_decode($encPath);
if (Request::get('isModule') === 'true') {
$filePath = $path;
} else {
$filePath = __DIR__ . '/../Assets/' . $path;
}
$fileName = basename($filePath);
if (!is_null($contentType)) {
$contentType = CryptoServiceFacade::url_decode($contentType);
} else {
$contentType = $fileSystem->mimeType($fileName);
}
$headers = ['Content-Type' => $contentType];
return response()->download($filePath, $fileName, $headers);
} catch (Exception $e) {
return Response::make('file not found');
}
}