Provide resource of tmp file instead of putting all content in memory

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-06-25 17:55:40 +02:00
parent 546928fb79
commit 014f76b2fb

View File

@@ -139,8 +139,11 @@ class FileService implements IAttachmentService {
if ($folder->fileExists($fileName)) { if ($folder->fileExists($fileName)) {
throw new StatusException('File already exists.'); throw new StatusException('File already exists.');
} }
$target = $folder->newFile($fileName); $target = $folder->newFile($fileName);
$target->putContent(file_get_contents($file['tmp_name'], 'r')); $content = fopen($file['tmp_name'], 'rb');
$target->putContent($content);
fclose($content);
$attachment->setData($fileName); $attachment->setData($fileName);
} }
@@ -156,7 +159,9 @@ class FileService implements IAttachmentService {
$attachment->setData($fileName); $attachment->setData($fileName);
$target = $this->getFileForAttachment($attachment); $target = $this->getFileForAttachment($attachment);
$target->putContent(file_get_contents($file['tmp_name'], 'r')); $content = fopen($file['tmp_name'], 'rb');
$target->putContent($content);
fclose($content);
$attachment->setLastModified(time()); $attachment->setLastModified(time());
} }