Hello,
Trying to resolve a bug in excising application with no knowledge transfer and no documentation.
We are on Apex 18.2
Large files over 30 Mb fail to upload:
Uploader wheel keeps spinning and uploader dialog would not close.
Upload button calls js function with ajax call to the page process.
Function and the process code below:
function uploadFile(pFileIndex) {
var fileCount = 0;
var file = fileInputElem.files[pFileIndex];
var reader = new FileReader();
var uploadTarget = apex.item("P3_UPLOAD_TARGET").getValue();
reader.onload = (function(pFile) {
return function(e) {
if (pFile) {
var base64 = binaryArray2base64(e.target.result);
var f01Array = [];
f01Array = clob2Array(base64, 30000, f01Array);
apex.server.process(
'UPLOAD_FILE',
{
x01: file.name,
x02: file.type,
x03: uploadTarget,
x04: apex.item("P3_FILE_TYPE").getValue(),
x05: parent.apex.item('P2_SCREEN_TYPE').getValue(),
f01: f01Array
},
{
dataType: 'json',
success: function(data) {
console.log('retn_status=' + data.j_retn_status);
if (data.j_retn_status == 'SUCCESS') {
if (fileIndex === 0) {
apex.item('P3_PRIMARY_ID').setValue(data.j_primary_id);
}
fileIndex++;
if (fileIndex < fileInputElem.files.length) {
// start uploading the next file
var d = fileIndex - 1;
uploadFile(fileIndex);
} else {
// all files have been uploaded at this point
apex.item('P3_FILES_COUNT').setValue(fileIndex);
fileInputElem.value = '';
deferredObject.resolve('done');
}
} else {
//alert('Something went terribly wrong. Please try again or contact your application administrator.' + data.j_retn_status);
console.log('ERROR ' + $('#FILEDISP'));
$('#FILEDISP'+pFileIndex).html($('#FILEDISP'+pFileIndex).text() + '<p class="fa-window-close" aria-hidden="true"></p>' ) ;
}
}
}
);
}
}
})(file);
$('#FILEDISP'+pFileIndex).html($('#FILEDISP'+pFileIndex).text() + '<p class="fa fa-check" aria-hidden="true"></p>' ) ;
reader.readAsArrayBuffer(file);
return deferredObject.promise();
}
-- Ajax Process Called by Page 3 Javascript:
DECLARE
p_in_file_name VARCHAR2(240) := apex_application.g_x01;
p_file_type assets.asset_type%TYPE := apex_application.g_x04; --:P3_ASSET_TYPE; -- IMG or DOC
p_mime_type VARCHAR2(80) := NVL(apex_application.g_x02,'application/octet-stream');
p_upload_target VARCHAR2(3) := apex_application.g_x03;
p_screen_type VARCHAR2(10) := apex_application.g_x05;
p_home_id homes.home_id%TYPE := :P3_HOME_ID;
p_employee_id employees.employee_id%TYPE := :GLB_EMPLOYEE_ID;
p_primary_id assets.asset_id%TYPE := NULL;
p_retn_status VARCHAR2(10) := 'SUCCESS';
p_retn_message VARCHAR2(400) := NULL;
BEGIN
------------------------------------------------------------------------------
-- Call database package to upload file --
BEGIN
ARIS0290.upload_file
(p_in_file_name , -- IN in_file_name
p_file_type , -- IN asset_type (IMG or DOC)
p_mime_type , -- IN mime_type
p_upload_target, -- IN upload_target
p_home_id , -- IN home_id
p_employee_id , -- IN employee_id
p_screen_type ,
p_primary_id , -- OUT primary_id
p_retn_status , -- OUT return status
p_retn_message -- OUT return message
);
END;
------------------------------------------------------------------------------
-- Set return status and message --
BEGIN
apex_json.open_object;
apex_json.WRITE('j_primary_id' ,p_primary_id);
apex_json.WRITE('j_retn_status' ,p_retn_status);
apex_json.WRITE('j_retn_message',p_retn_message);
apex_json.close_object;
END;
------------------------------------------------------------------------------
END;
Will greatly appreciate your help!