diff --git a/lib/Controller/WopiController.php b/lib/Controller/WopiController.php index 27d85dbcad..593c939122 100644 --- a/lib/Controller/WopiController.php +++ b/lib/Controller/WopiController.php @@ -485,10 +485,21 @@ public function putFile($fileId, $content = fopen('php://input', 'rb'); + // Get expected FileSize after writing + $storage = \OC_Helper::getStorageInfo($path); + fseek($content,0,SEEK_END); + $finalSize = ftell($content) + $file->getSize(); + rewind( $content ); + try { - $this->wrappedFilesystemOperation($wopi, function () use ($file, $content) { - return $file->putContent($content); - }); + if ($finalSize <= $storage['free']){ + $this->wrappedFilesystemOperation($wopi, function () use ($file, $content) { + return $file->putContent($content); + }); + } + else { + throw new \Exception('Not enough storage'); + } } catch (LockedException $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); return new JSONResponse(['message' => 'File locked'], Http::STATUS_INTERNAL_SERVER_ERROR);