當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。