我希望改变APEX上传文件的方式。我不想把文件作为BLOB存储到数据库表中,而是希望它们直接保存在运行APEX的机器上的操作系统目录中。这样是否可行?如果可行,我需要从哪里开始?
我希望改变APEX上传文件的方式。我不想把文件作为BLOB存储到数据库表中,而是希望它们直接保存在运行APEX的机器上的操作系统目录中。这样是否可行?如果可行,我需要从哪里开始?
BLOB
列。如果没有在指定的表中,它将进入wwv_flow_files
(apex_application_files
)这是备选项。然而这不应该成为致命问题,因为在处理完BLOB
后您可以轻松清理该表。
Create a procedure that will write a BLOB
to a file. An example of this
technique is here (dba-oracle.com). In short, what that will do
is:
open up a file on the filesystem (a directory is required, and a directory is referred to by the name of the directory object you
created earlier!)
-- define output directory
l_output := utl_file.fopen('DIR_TEMP', 'filename','wb', 32760);
In this example code, the created directory is the DIR_TEMP
object
BLOB
is small enough to be written in 1 go)wwv_flow_files
BLOB
as in IN
parameter.示例 Apex 流程:
DECLARE
v_upl_blob BLOB;
BEGIN
SELECT blob_content
INTO v_upl_blob
FROM wwv_flow_files
WHERE name = :Px_FILE_BROWSE_ITEM;
my_file_write_procedure(v_upl_blob);
DELETE FROM wwv_flow_files
WHERE name = :Px_FILE_BROWSE_ITEM;
END;
如果您需要更多的文档资料,当然可以使用谷歌搜索,或查看所有在此处使用的对象的Oracle文档,甚至可以参考Oracle论坛(例如OTN apex论坛 或 OTN PL/SQL论坛)。
declare
v_length number;
v_id number;
begin
select doc_size
into v_length
from wwv_flow_files
where name = :P105_PIC;
if v_length > 20000 then
delete from wwv_flow_files where name = :P105_PIC;
commit;
apex_error.add_error (
p_message => 'Cannot upload pictures bigger than 20kB!',
p_display_location => apex_error.c_inline_in_notification );
end if;
exception
when others then
apex_error.add_error (
p_message => 'Cannot upload pictures!',
p_display_location => apex_error.c_inline_in_notification );
end;