Exemplo n.º 1
0
 public function RenderAction(\SW\DocManagerBundle\Entity\Document $document)
 {
     $path = $document->getPath();
     $response = new BinaryFileResponse($path);
     $response->trustXSendfileTypeHeader();
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_INLINE, $document->getName());
     return $response;
 }
 protected function upload($temporary, Document $document)
 {
     if ($temporary) {
         $file = $document->getFile();
         if (null === $document->getFile()) {
             return;
         }
         //$this->creator = $this->file->getClientOriginalName();
         $file = $file->move($this->getUploadTempDir(), $file->getFilename());
         $document->setFile($file);
         $document->setPath($this->getUploadTempDir() . '/' . $file->getFilename());
         $document->setAlt($document->getCode());
     } else {
         $file = new File($document->getPath());
         if (null === $file) {
             return;
         }
         $file = $file->move($this->getUploadRootDir(), $document->getName());
         $document->setPath($this->getUploadRootDir() . '/' . $file->getFilename());
     }
     return $document;
 }