aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarcel Klehr <mklehr@gmx.net>2024-07-13 11:40:39 +0200
committerMarcel Klehr <mklehr@gmx.net>2024-07-17 13:55:55 +0200
commiteb0b5f29fb3cfa3c02edc3b9a42e96ed6a10baaf (patch)
tree213659091fbe2496d2b5e4bbf4d622cfd62d3b77 /core
parentee7502ab1c126d4bf744bea816c602ef3a458e35 (diff)
downloadnextcloud-server-eb0b5f29fb3cfa3c02edc3b9a42e96ed6a10baaf.tar.gz
nextcloud-server-eb0b5f29fb3cfa3c02edc3b9a42e96ed6a10baaf.zip
fix(TaskProcessingApiController): Address review comments
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
Diffstat (limited to 'core')
-rw-r--r--core/Controller/TaskProcessingApiController.php10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/Controller/TaskProcessingApiController.php b/core/Controller/TaskProcessingApiController.php
index 289597a110f..1107b13d964 100644
--- a/core/Controller/TaskProcessingApiController.php
+++ b/core/Controller/TaskProcessingApiController.php
@@ -309,11 +309,11 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
if (!isset($file['tmp_name'])) {
return new DataResponse(['message' => $this->l->t('Bad request')], Http::STATUS_BAD_REQUEST);
}
- $data = file_get_contents($file['tmp_name']);
- if (!$data) {
+ $handle = fopen($file['tmp_name'], 'r');
+ if (!$handle) {
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
}
- $fileId = $this->setFileContentsInternal($data);
+ $fileId = $this->setFileContentsInternal($handle);
return new DataResponse(['fileId' => $fileId], Http::STATUS_CREATED);
} catch (NotFoundException) {
return new DataResponse(['message' => $this->l->t('Not found')], Http::STATUS_NOT_FOUND);
@@ -530,14 +530,14 @@ class TaskProcessingApiController extends \OCP\AppFramework\OCSController {
}
}
- private function setFileContentsInternal(string $data): int {
+ private function setFileContentsInternal($data): int {
try {
$folder = $this->appData->getFolder('TaskProcessing');
} catch (\OCP\Files\NotFoundException) {
$folder = $this->appData->newFolder('TaskProcessing');
}
/** @var SimpleFile $file */
- $file = $folder->newFile((string) rand(0, 10000000), $data);
+ $file = $folder->newFile(time() . '-' . rand(1, 100000), $data);
return $file->getId();
}
}