| @@ 56-68 (lines=13) @@ | ||
| 53 | // TODO: use proc_open() and stream the source file ? |
|
| 54 | ||
| 55 | $useFileDirectly = (!$file->isEncrypted() && !$file->isMounted()); |
|
| 56 | if ($useFileDirectly) { |
|
| 57 | $absPath = $file->getStorage()->getLocalFile($file->getInternalPath()); |
|
| 58 | } else { |
|
| 59 | $absPath = \OC::$server->getTempManager()->getTemporaryFile(); |
|
| 60 | ||
| 61 | $handle = $file->fopen('rb'); |
|
| 62 | ||
| 63 | // we better use 5MB (1024 * 1024 * 5 = 5242880) instead of 1MB. |
|
| 64 | // in some cases 1MB was no enough to generate thumbnail |
|
| 65 | $firstmb = stream_get_contents($handle, 5242880); |
|
| 66 | file_put_contents($absPath, $firstmb); |
|
| 67 | fclose($handle); |
|
| 68 | } |
|
| 69 | ||
| 70 | $result = $this->generateThumbNail($maxX, $maxY, $absPath, 5); |
|
| 71 | if ($result === false) { |
|
| @@ 46-54 (lines=9) @@ | ||
| 43 | public function getThumbnail(File $file, $maxX, $maxY, $scalingUp) { |
|
| 44 | ||
| 45 | $useFileDirectly = (!$file->isEncrypted() && !$file->isMounted()); |
|
| 46 | if ($useFileDirectly) { |
|
| 47 | $absPath = $file->getStorage()->getLocalFile($file->getInternalPath()); |
|
| 48 | } else { |
|
| 49 | $absPath = \OC::$server->getTempManager()->getTemporaryFile(); |
|
| 50 | ||
| 51 | $handle = $file->fopen('rb'); |
|
| 52 | file_put_contents($absPath, $handle); |
|
| 53 | fclose($handle); |
|
| 54 | } |
|
| 55 | ||
| 56 | $getID3 = new ID3Parser(); |
|
| 57 | $tags = $getID3->analyze($absPath); |
|
| @@ 43-51 (lines=9) @@ | ||
| 40 | } |
|
| 41 | ||
| 42 | $useFileDirectly = (!$file->isEncrypted() && !$file->isMounted()); |
|
| 43 | if ($useFileDirectly) { |
|
| 44 | $absPath = $file->getStorage()->getLocalFile($file->getInternalPath()); |
|
| 45 | } else { |
|
| 46 | $absPath = \OC::$server->getTempManager()->getTemporaryFile(); |
|
| 47 | ||
| 48 | $handle = $file->fopen('rb'); |
|
| 49 | file_put_contents($absPath, $handle); |
|
| 50 | fclose($handle); |
|
| 51 | } |
|
| 52 | ||
| 53 | $tmpDir = \OC::$server->getTempManager()->getTempBaseDir(); |
|
| 54 | ||