コード例 #1
0
 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()}"));
 }
コード例 #2
0
 public function setSourceImageFile(\Filehosting\Model\File $file)
 {
     $this->sourceImageFile = $file;
     $this->imageExtension = $file->getExtension();
 }
コード例 #3
0
 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;
 }
コード例 #4
0
ファイル: Comment.php プロジェクト: blackberryJam/filehosting
 public function setFile(File $file)
 {
     $file->addComment($this);
     $this->file = $file;
 }