public function showFile($id, $idFile)
 {
     $model = $this->repository->skipPresenter()->find($idFile);
     $filePath = $this->service->getFilePath($idFile);
     $fileContent = file_get_contents($filePath);
     $file64 = base64_encode($fileContent);
     return ['file' => $file64, 'size' => filesize($filePath), 'name' => $this->service->getFileName($idFile), 'mime_type' => $this->storage->mimeType($model->getFileName())];
 }
 /**
  * @param $projectId
  * @param $fileId
  * @return array|mixed
  */
 public function download($projectId, $fileId)
 {
     try {
         $model = $this->repository->skipPresenter()->find($fileId);
         $filePath = $this->service->getFilePath($fileId);
         $fileContent = file_get_contents($filePath);
         $file64 = base64_encode($fileContent);
         $fileBd = $this->repository->skipPresenter()->find($fileId);
         return ['data' => ['file' => $file64, 'size' => filesize($filePath), 'fileName' => $fileBd->getFileName(), 'name' => $fileBd->name, 'description' => $fileBd->description, 'extension' => $fileBd->extension, 'mime_type' => $this->storage->mimeType($model->getFileName())]];
     } catch (ModelNotFoundException $e) {
         return ['error' => true, 'message' => 'Não foi possível encontrar o registro'];
     } catch (\Exception $e) {
         return ["error" => true, "message" => $e->getMessage()];
     }
 }
 public function showFile($id, $idFile)
 {
     if ($this->projectService->checkProjectPermissions($id) == false) {
         return ['error' => 'Access Forbidden'];
     }
     $model = $this->repository->skipPresenter()->find($idFile);
     $filePath = $this->service->getFilePath($idFile);
     $fileContent = file_get_contents($filePath);
     $file64 = base64_encode($fileContent);
     return ['file' => $file64, 'size' => filesize($filePath), 'name' => $this->service->getFileName($idFile), 'mime_type' => $this->storage->mimeType($model->getFileName())];
 }
 public function download($project_id, $file_id)
 {
     /*if( $this->service->checkProjectPermissions($project_id) == false ){
           return ['error' => 'Acesso negado'];
       }*/
     #return response()->download($this->service->show($file_id));
     $model = $this->repository->skipPresenter()->find($file_id);
     $file_path = $this->service->show($file_id);
     $file_content = file_get_contents($file_path);
     $file64 = base64_encode($file_content);
     return ['file' => $file64, 'size' => filesize($file_path), 'name' => $this->service->getFileName($file_id), 'mime_type' => $this->storage->mimeType($this->service->getFileName($file_id))];
 }
Exemplo n.º 5
0
 /**
  * Download a file.
  */
 public function downloadFile($path)
 {
     $path = $this->cleanFolder($path);
     $parts = explode('/', $path);
     $filename = array_pop($parts);
     $content = $this->fileSystem->get($path);
     $mime = $this->fileSystem->mimeType($path);
     if (!$this->fileSystem->exists($path)) {
         throw new FileDoesNotExist('File does not exist.');
     }
     return response($content, 200)->header('Content-Type', $mime)->header('Content-Disposition', 'attachment; filename="' . $filename . '"');
 }