当用户使用Oracle APEX中的“文件浏览”项选择图像/文档时,需要通过ORDS REST API将该图像/文档传输到远程DB。ORDS POST API是在remove DB上创建的,它接受类似内容的参数,类型等。并插入详细信息到数据库。它是工作查找,但不知何故BLOB(图像/文档)在远程数据库中损坏。以下是在Oracle APEX页面中创建的项目详细信息-
x1c 0d1x的数据
使用此项目上传的图像/文档将进入APEX临时表(apex_application_temp_files)。现在,当用户单击“上传”时,以下JavaScript将被执行-
//alert('here');
var base64Image = "";
var fileName = $v('P28_NEW');
var getImageDetails = async function() {
//alert('inside get image details func');
return apex.server.process(
"GET_IMAGE_DETAILS", {
x01: fileName
}, {
async: false,
dataType: "json",
success: function(pData) {
console.log('success');
console.log('requestBody:'+JSON.stringify(pData));
},
error: function(request, status, error) {
alert("Error1:" + error);
},
}
);
};
async function mainFunction() {
try {
var callFunction1 = await getImageDetails();
var apiUrl = '...../ords/..../..../image/api?TITLE=test&FILENAME=test&SUBMITTED_BY=ssss&MIMETYPE=application/pdf';
var imageContent = callFunction1.image;
var imageType = callFunction1.mimetype;
//console.log('requestBody:'+JSON.stringify(callFunction1));
fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: imageContent
})
.then(function(response) {
if (response.ok) {
console.log('successful');
} else {
console.error('failed');
}
})
.catch(function(error) {
console.error('Error:', error);
});
} catch (e) {
console.error(e);
}
}
mainFunction();
字符串
此JavaScript函数调用一个AJAX进程来获取上传的图像/文档的内容-
DECLARE
l_image CLOB;
l_mime_type VARCHAR2 (255);
l_imag1e varchar2(500):= APEX_APPLICATION.g_x01;
BEGIN
SELECT blob_content, mime_type
INTO l_image, l_mime_type
FROM apex_application_temp_files
WHERE name = l_imag1e;
-- Return the values using apex_json package
apex_json.open_object;
apex_json.write('image', l_image);
apex_json.write('mimetype', l_mime_type);
apex_json.close_object;
exception
when others then
apex_json.open_object;
apex_json.write('message', sqlerrm);
apex_json.close_object;
--htp.p(sqlerrm);
END;
型
ORDS REST API,在远程DB上创建。它使用“:body”参数提取内容。
的
1条答案
按热度按时间xytpbqjk1#
在PL/SQL代码块中,您获取列
blob_content
并将其放入l_image,一个clob变量。你试过通过
apex_web_service.blob2clobbase64
转换blob_content吗?字符串
当然,您需要在目标DB中将其转换回blob,例如使用
APEX_WEB_SERVICE.CLOBBASE642BLOB
。