Verified Commit da66b9f5 authored by Cyril Vazquez's avatar Cyril Vazquez
Browse files

Temp fix by keeping base64 until resource validation

parent 35873253
Pipeline #6276 failed with stage
......@@ -659,13 +659,20 @@ trait archiveModificationTrait
// Valid URL file:// http:// data://
if (filter_var($contents, FILTER_VALIDATE_URL)) {
$contents = stream_get_contents($contents);
// Encode to base64 because validateDigitalResource decodes it !
$contents = base64_encode($contents);
} elseif (preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $contents)) {
$contents = base64_decode($contents);
// Avoid decode from base64 because validateDigitalResource decodes it !
//$contents = base64_decode($contents);
} elseif (is_file($contents)) {
if (empty($filename)) {
$filename = basename($contents);
}
$contents = file_get_contents($contents);
// Encode to base64 because validateDigitalResource decodes it !
$contents = base64_encode($contents);
} else {
throw new \core\Exception\BadRequestException();
}
$digitalResource = $this->digitalResourceController->createFromContents($contents, $filename);
......
......@@ -23,6 +23,13 @@
</table>
</div>
<div class="hide">
<!-- ERROR MESSAGE -->
<div data-translate-catalog="recordsManagement/message">
<span id="emptyResource_error">Your ressource is empty</span>
</div>
</div>
<style type="text/css">
#resource_XMLDropZone {
border: 2px dashed grey;
......@@ -63,11 +70,16 @@
type : null
}
fileObject.binary = oFileReader.result.replace(/(^data:|;base64,)|(^data:.*?;base64,)/, "");
fileObject.binary = oFileReader.result.replace(/(^data:.*?;base64,)/, "");
fileObject.fileName = file.name;
fileObject.size = file.size;
fileObject.type = file.type;
if (fileObject.size == 0) {
gritter.show($('#emptyResource_error').text(), false);
return -1;
}
if ((fileObject.type == "application/x-zip-compressed" || fileObject.type == "application/zip") && resourceList.card == 0) {
$('#resource_XMLDropZone').addClass('hide');
$('#resourceForm').find("[name=zipContainer]").prop('checked', true).parent().removeClass('hide');
......
Supports Markdown
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