diff options
author | Imbasaur <yarrusg@gmail.com> | 2016-04-13 17:05:59 +0200 |
---|---|---|
committer | Imbasaur <yarrusg@gmail.com> | 2016-04-13 17:05:59 +0200 |
commit | 99f275e5bb033cca33eee87b0e914645730f13d1 (patch) | |
tree | ad845419d56304f2bf014744f0878186f7155a3c /app/Model/File.php | |
parent | 13d5bd8e48bd6c0109d1272da58a8879bf9a6737 (diff) | |
parent | cd5bf9d4d214ec9282b706c26bb27cabf150ee63 (diff) |
Merge pull request #1 from fguillot/master
Diffstat (limited to 'app/Model/File.php')
-rw-r--r-- | app/Model/File.php | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/app/Model/File.php b/app/Model/File.php index 03ea691d..e383235c 100644 --- a/app/Model/File.php +++ b/app/Model/File.php @@ -3,8 +3,8 @@ namespace Kanboard\Model; use Exception; +use Kanboard\Core\Thumbnail; use Kanboard\Event\FileEvent; -use Kanboard\Core\Tool; use Kanboard\Core\ObjectStorage\ObjectStorageException; /** @@ -315,15 +315,15 @@ abstract class File extends Base */ public function generateThumbnailFromData($destination_filename, &$data) { - $temp_filename = tempnam(sys_get_temp_dir(), 'datafile'); + $blob = Thumbnail::createFromString($data) + ->resize() + ->toString(); - file_put_contents($temp_filename, $data); - $this->generateThumbnailFromFile($temp_filename, $destination_filename); - unlink($temp_filename); + $this->objectStorage->put($this->getThumbnailPath($destination_filename), $blob); } /** - * Generate thumbnail from a blob + * Generate thumbnail from a local file * * @access public * @param string $uploaded_filename @@ -331,8 +331,10 @@ abstract class File extends Base */ public function generateThumbnailFromFile($uploaded_filename, $destination_filename) { - $thumbnail_filename = tempnam(sys_get_temp_dir(), 'thumbnail'); - Tool::generateThumbnail($uploaded_filename, $thumbnail_filename); - $this->objectStorage->moveFile($thumbnail_filename, $this->getThumbnailPath($destination_filename)); + $blob = Thumbnail::createFromFile($uploaded_filename) + ->resize() + ->toString(); + + $this->objectStorage->put($this->getThumbnailPath($destination_filename), $blob); } } |