当前位置: 首页>>代码示例>>PHP>>正文


PHP Filesystem::mimeType方法代码示例

本文整理汇总了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);
 }
开发者ID:rudenyl,项目名称:orocms-plugin-summernote,代码行数:14,代码来源:SummerNoteController.php

示例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);
 }
开发者ID:alexandermakedonski,项目名称:hoursystem,代码行数:22,代码来源:AvatarController.php

示例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);
 }
开发者ID:recca0120,项目名称:laravel-elfinder,代码行数:29,代码来源:ElfinderController.php

示例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);
 }
开发者ID:satriashp,项目名称:tour,代码行数:11,代码来源:_ide_helper.php

示例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');
     }
 }
开发者ID:YABhq,项目名称:Quarx,代码行数:29,代码来源:AssetController.php


注:本文中的Illuminate\Filesystem\Filesystem::mimeType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。