/**
  * 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);
 }
 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);
 }
 /**
  * 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);
 }
Example #4
0
 /**
  * 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);
 }
Example #5
0
 /**
  * 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');
     }
 }