protected function showImage(Application $app, File $file, $mode)
 {
     if (null === $file->getThumbnailPath()) {
         return $app->redirect("/file/{$file->getId()}");
     }
     $ext = $file->getExtension();
     $ext = $ext === "jpg" ? "jpeg" : $ext;
     $imagecreate = "imagecreatefrom{$ext}";
     $image = "image{$ext}";
     switch ($mode) {
         case 'thumb':
             $im = $imagecreate("{$app['file.save_directory']}/{$file->getThumbnailPath()}");
             break;
         case 'original':
             $im = $imagecreate("{$app['file.save_directory']}/{$file->getPath()}");
             break;
     }
     return new Response($image($im), 200, array("Content-Type" => "{$file->getMimeType()}"));
 }
 public function setSourceImageFile(\Filehosting\Model\File $file)
 {
     $this->sourceImageFile = $file;
     $this->imageExtension = $file->getExtension();
 }
 protected function convertSavedFileToEntity($uploadedFile, $newName)
 {
     $file = new File();
     $file->setPath("{$this->destinationFolder}/{$newName}");
     $file->setOriginalName($uploadedFile->getClientOriginalName());
     $file->setMimeType($uploadedFile->getMimeType());
     $file->setDateUpload(new \DateTime());
     $file->setMediaInfo($this->extractMediaInfo($uploadedFile));
     $file->setUser($this->user);
     $file->setSize($uploadedFile->getSize());
     return $file;
 }
Example #4
0
 public function setFile(File $file)
 {
     $file->addComment($this);
     $this->file = $file;
 }