diff --git a/src/bundle/digitalResource/Controller/format.php b/src/bundle/digitalResource/Controller/format.php index bce57b1b086b55a7dc70131097fd9b00e90fa61d..5760514069e10e3f698ce91b975d10b519baef4e 100755 --- a/src/bundle/digitalResource/Controller/format.php +++ b/src/bundle/digitalResource/Controller/format.php @@ -183,13 +183,20 @@ class format /** * Get all information about the content file (puid, md5/sha256/sha512 hash) - * @param string $contents The content file * * @return digitalResource/fileInformation The file information object */ - public function getFileInformation($contents) + public function getFileInformation($contents, $extension) { - $contents = base64_decode($contents); + if (is_resource($contents)) { + $contents = base64_decode(stream_get_contents($contents)); + } elseif (filter_var($contents, FILTER_VALIDATE_URL)) { + $contents = stream_get_contents($contents); + } elseif (preg_match('%^[a-zA-Z0-9\\\\/+]*={0,2}$%', $contents)) { + $contents = base64_decode($contents); + } elseif (is_file($contents)) { + $contents = file_get_contents($contents); + } $filename = tempnam(sys_get_temp_dir(), 'digitalResource.format.'); file_put_contents($filename, $contents); diff --git a/src/bundle/digitalResource/formatInterface.php b/src/bundle/digitalResource/formatInterface.php index 272c394903a302984cb118760d3fae7c159cbe34..ac3f9a055e1d75cfc9c9ec1a27be5e54b7d0c989 100755 --- a/src/bundle/digitalResource/formatInterface.php +++ b/src/bundle/digitalResource/formatInterface.php @@ -48,8 +48,7 @@ interface formatInterface /** * Get the list of type - * @param string $contents - * @param string $extension + * * @action digitalResource/format/getFileInformation */ public function createFileformatinformation($contents, $extension); diff --git a/src/presentation/maarchRM/Resources/view/digitalResource/format/index.html b/src/presentation/maarchRM/Resources/view/digitalResource/format/index.html index a337b5a758cc9a19cb247c426c29df06be294332..ce8cac211707e1b551d5cba5979c12c965d7a5a5 100755 --- a/src/presentation/maarchRM/Resources/view/digitalResource/format/index.html +++ b/src/presentation/maarchRM/Resources/view/digitalResource/format/index.html @@ -246,7 +246,7 @@ file that was distributed with this source code. contents : file.contents, extension : file.extension },*/ - data : JSON.stringify({contents : file.contents, extension : file.extension}), + data : JSON.stringify({'contents' : file.contents, 'extension' : file.extension}), contentType : 'application/json', dataType : 'json', success : function (response) {