public function asPreview($encFileName, Filesystem $fileSystem)
    {
        try {
            return Cache::remember($encFileName.'_preview', 3600, function () use ($encFileName, $fileSystem) {
                $fileName = CryptoServiceFacade::url_decode($encFileName);

                if (config('cms.storage-location') === 'local' || config('cms.storage-location') === null) {
                    $filePath = storage_path('app/'.$fileName);
                    $contentType = $fileSystem->mimeType($filePath);
                    $ext = strtoupper($fileSystem->extension($filePath));
                } else {
                    $filePath = Storage::disk(config('cms.storage-location', 'local'))->url($fileName);
                    $fileTool = new SplFileInfo($filePath);
                    $ext = $fileTool->getExtension();
                    $contentType = $this->getMimeType($ext);
                }

                if (stristr($contentType, 'image')) {
                    $headers = ['Content-Type' => $contentType];
                    $fileContent = $this->getFileContent($fileName, $contentType, $ext);
                } else {
                    $fileContent = file_get_contents($this->generateImage($ext));
                }

                return Response::make($fileContent, 200, [
                    'Content-Type' => $contentType,
                    'Content-Disposition' => 'attachment; filename="'.$fileName.'"',
                ]);
            });
        } catch (Exception $e) {
            return Response::make('file not found');
        }
    }
public function asPreview($encFileName, Filesystem $fileSystem)
    {
        try {
            return Cache::remember($encFileName.'_preview', 3600, function () use ($encFileName, $fileSystem) {
                $fileName = CryptoServiceFacade::url_decode($encFileName);

                if (config('cms.storage-location') === 'local' || config('cms.storage-location') === null) {
                    $filePath = storage_path('app/'.$fileName);
                    $contentType = $fileSystem->mimeType($filePath);
                    $ext = strtoupper($fileSystem->extension($filePath));
                } else {
                    $filePath = Storage::disk(config('cms.storage-location', 'local'))->url($fileName);
                    $fileTool = new SplFileInfo($filePath);
                    $ext = $fileTool->getExtension();
                    $contentType = $this->getMimeType($ext);
                }

                if (stristr($contentType, 'image')) {
                    $headers = ['Content-Type' => $contentType];
                    $fileContent = $this->getFileContent($fileName, $contentType, $ext);
                } else {
                    $fileContent = file_get_contents($this->generateImage($ext));
                }

                return Response::make($fileContent, 200, [
                    'Content-Type' => $contentType,
                    'Content-Disposition' => 'attachment; filename="'.$fileName.'"',
                ]);
            });
        } catch (Exception $e) {
            return Response::make('file not found');
        }
    }
public function asPreview ( $ encFileName , Filesystem $ fileSystem ) { try { return Cache :: remember ( $ encFileName . '_preview' , 3600 , function ( ) use ( $ encFileName , $ fileSystem ) { $ fileName = CryptoServiceFacade :: url_decode ( $ encFileName ) ; if ( config ( 'cms.storage-location' ) === 'local' || config ( 'cms.storage-location' ) === null ) { $ filePath = storage_path ( 'app/' . $ fileName ) ; $ contentType = $ fileSystem -> mimeType ( $ filePath ) ; $ ext = strtoupper ( $ fileSystem -> extension ( $ filePath ) ) ; } else { $ filePath = Storage :: disk ( config ( 'cms.storage-location' , 'local' ) ) -> url ( $ fileName ) ; $ fileTool = new SplFileInfo ( $ filePath ) ; $ ext = $ fileTool -> getExtension ( ) ; $ contentType = $ this -> getMimeType ( $ ext ) ; } if ( stristr ( $ contentType , 'image' ) ) { $ headers = [ 'Content-Type' => $ contentType ] ; $ fileContent = $ this -> getFileContent ( $ fileName , $ contentType , $ ext ) ; } else { $ fileContent = file_get_contents ( $ this -> generateImage ( $ ext ) ) ; } return Response :: make ( $ fileContent , 200 , [ 'Content-Type' => $ contentType , 'Content-Disposition' => 'attachment; filename="' . $ fileName . '"' , ] ) ; } ) ; } catch ( Exception $ e ) { return Response :: make ( 'file not found' ) ; } }
Provide the File as a Public Preview.

@param string $encFileName

@return Download
Provide the File as a Public Preview .