Commit 909fdb4b authored by Cyril Vazquez's avatar Cyril Vazquez

Merge branch 'fix/13343_Read_Resource_from_API' into 'Support/2.6.X'

Get size from temp file

See merge request !432
parents 7e9c0d8f fe43bedd
Pipeline #7039 failed with stages
......@@ -392,10 +392,6 @@ trait archiveValidationTrait
*/
public function validateDigitalResource($digitalResource)
{
if ($digitalResource->size == 0) {
throw new \bundle\recordsManagement\Exception\invalidArchiveException('Resource size is null', 400);
}
// Create temp file
$handler = $digitalResource->getHandler();
$filename = tempnam(sys_get_temp_dir(), 'digitalResource.format');
......@@ -406,6 +402,10 @@ trait archiveValidationTrait
$digitalResource->size = filesize($filename);
if ($digitalResource->size == 0) {
throw new \bundle\recordsManagement\Exception\invalidArchiveException('Resource size is null', 400);
}
if (!isset($digitalResource->mimetype)) {
$finfo = new \finfo();
$mimetype = $finfo->file($filename, FILEINFO_MIME_TYPE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment