fix getting uploaded files

This commit is contained in:
Uwe Steinmann 2025-01-02 14:40:49 +01:00
parent 267c8c468b
commit ee6d2f15fc

View File

@ -775,7 +775,9 @@ final class SeedDMS_RestapiController { /* {{{ */
$workflow = array_shift($workflows); $workflow = array_shift($workflows);
} }
} }
$temp = $file_info->file; $temp = tempnam(sys_get_temp_dir(), 'FOO');
file_put_contents($temp, (string) $file_info->getStream());
$finfo = finfo_open(FILEINFO_MIME_TYPE); $finfo = finfo_open(FILEINFO_MIME_TYPE);
$userfiletype = finfo_file($finfo, $temp); $userfiletype = finfo_file($finfo, $temp);
$fileType = ".".pathinfo($origfilename, PATHINFO_EXTENSION); $fileType = ".".pathinfo($origfilename, PATHINFO_EXTENSION);
@ -914,7 +916,8 @@ final class SeedDMS_RestapiController { /* {{{ */
$file_info = array_pop($uploadedFiles); $file_info = array_pop($uploadedFiles);
if ($origfilename == null) if ($origfilename == null)
$origfilename = $file_info->getClientFilename(); $origfilename = $file_info->getClientFilename();
$temp = $file_info->file; $temp = tempnam(sys_get_temp_dir(), 'FOO');
file_put_contents($temp, (string) $file_info->getStream());
/* Check if the uploaded file is identical to last version */ /* Check if the uploaded file is identical to last version */
$lc = $document->getLatestContent(); $lc = $document->getLatestContent();
@ -1047,7 +1050,7 @@ final class SeedDMS_RestapiController { /* {{{ */
$keywords = isset($params['keywords']) ? $params['keywords'] : ''; $keywords = isset($params['keywords']) ? $params['keywords'] : '';
$origfilename = isset($params['origfilename']) ? $params['origfilename'] : null; $origfilename = isset($params['origfilename']) ? $params['origfilename'] : null;
$content = $request->getBody(); $content = $request->getBody();
$temp = tempnam('/tmp', 'lajflk'); $temp = tempnam(sys_get_temp_dir(), 'lajflk');
$handle = fopen($temp, "w"); $handle = fopen($temp, "w");
fwrite($handle, $content); fwrite($handle, $content);
fclose($handle); fclose($handle);
@ -1115,7 +1118,8 @@ final class SeedDMS_RestapiController { /* {{{ */
$origfilename = $file_info->getClientFilename(); $origfilename = $file_info->getClientFilename();
if (trim($docname) == '') if (trim($docname) == '')
$docname = $origfilename; $docname = $origfilename;
$temp = $file_info->file; $temp = tempnam(sys_get_temp_dir(), 'FOO');
file_put_contents($temp, (string) $file_info->getStream());
$finfo = finfo_open(FILEINFO_MIME_TYPE); $finfo = finfo_open(FILEINFO_MIME_TYPE);
$userfiletype = finfo_file($finfo, $temp); $userfiletype = finfo_file($finfo, $temp);
$fileType = ".".pathinfo($origfilename, PATHINFO_EXTENSION); $fileType = ".".pathinfo($origfilename, PATHINFO_EXTENSION);