From 014f76b2fb5088389c3fd9de565e747a8d010d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 25 Jun 2018 17:55:40 +0200 Subject: [PATCH] Provide resource of tmp file instead of putting all content in memory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Service/FileService.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Service/FileService.php b/lib/Service/FileService.php index 16726f6f2..50b71f6fd 100644 --- a/lib/Service/FileService.php +++ b/lib/Service/FileService.php @@ -139,8 +139,11 @@ class FileService implements IAttachmentService { if ($folder->fileExists($fileName)) { throw new StatusException('File already exists.'); } + $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); } @@ -156,7 +159,9 @@ class FileService implements IAttachmentService { $attachment->setData($fileName); $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()); }