Skip to content

Commit 944e422

Browse files
committed
fix(TaskProcessing): Add file extension for files uploaded from ex apps
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent d00566f commit 944e422

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

core/Controller/TaskProcessingApiController.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,8 @@ public function setFileContentsExApp(int $taskId): DataResponse {
534534
if (!$handle) {
535535
return new DataResponse(['message' => $this->l->t('Internal error')], Http::STATUS_INTERNAL_SERVER_ERROR);
536536
}
537-
$fileId = $this->setFileContentsInternal($handle);
537+
$ext = pathinfo($file['name'], PATHINFO_EXTENSION);
538+
$fileId = $this->setFileContentsInternal($handle, $ext);
538539
return new DataResponse(['fileId' => $fileId], Http::STATUS_CREATED);
539540
} catch (NotFoundException) {
540541
return new DataResponse(['message' => $this->l->t('Not found')], Http::STATUS_NOT_FOUND);
@@ -854,14 +855,14 @@ public function getNextScheduledTaskBatch(array $providerIds, array $taskTypeIds
854855
* @return int
855856
* @throws NotPermittedException
856857
*/
857-
private function setFileContentsInternal($data): int {
858+
private function setFileContentsInternal($data, string $ext = ''): int {
858859
try {
859860
$folder = $this->appData->getFolder('TaskProcessing');
860861
} catch (\OCP\Files\NotFoundException) {
861862
$folder = $this->appData->newFolder('TaskProcessing');
862863
}
863864
/** @var SimpleFile $file */
864-
$file = $folder->newFile(time() . '-' . rand(1, 100000), $data);
865+
$file = $folder->newFile(time() . '-' . rand(1, 100000) . ($ext ? '.' . $ext : ''), $data);
865866
return $file->getId();
866867
}
867868

0 commit comments

Comments
 (0)