使用卡片区域下载 BLOB 文件 - Oracle Apex v21.1
Download a BLOB file using the Cards Region - Oracle Apex v21.1
我正在尝试创建某种“档案”页面,用户可以在其中下载前几年的报告。为此,我首先尝试创建一个 table 来保存我的文档(带有 MIMETYPE、BLOB、FILENAME、CHARSET 列等)。
CREATE TABLE tb_document
(
pk_document NUMBER,
nom_document VARCHAR2(4000),
mimetype_document VARCHAR2(512),
charset_document VARCHAR2(512),
blob_document VARCHAR2(512),
comment_document VARCHAR2(4000),
tags_document VARCHAR2(4000),
creation_document TIMESTAMP(6),
PRIMARY KEY(pk_document)
);
上传一些文件后,我有这样的报告:
点击下载图标,我可以成功下载文件。
但是,我不喜欢报告的外观。然后我尝试创建一个卡片区域,它将显示我的文件,这是我所做的,我更喜欢它:
问题是我不再下载 BLOB link,所以我尝试向卡片区域添加一个 action,通过单击它,将重定向到特定的 URL
这引出了我的问题,与 BLOB 下载 link 执行相同操作的 URL 是什么,然后如何下载特定文件我正在点击卡片?
请随时询问更多详情,提前致谢,
托马斯
我使用此处建议的解决方案进行 blob 下载:"Download Blob" using Interactive Grid
我的(正常)link 正在重定向到第 9000 页(请参阅上面的第 3 点 link)并将我的主行 ID 分配给 P9000_FILE_ID 项目。
工作量很大,但我可以推荐这个解决方案,因为它描述得很好并且工作正常。
虽然我没有尝试使用卡片,但我使用交互式网格来触发它,但只要你的主要 ID 使用带有 link 的解决方案,我认为也应该适用于卡片。
希望以上link对您有所帮助。
我得到了这个结果:
这给了我这些下载:
这是我的做法:
1.在 SQL 命令中创建此过程
CREATE OR REPLACE PROCEDURE get_file (p_file_id IN VARCHAR2) IS --The parameter will be the ID of the file in my document table
l_blob_content tb_document.blob_document%TYPE; --The BLOB FILE
l_mime_type tb_document.mimetype_document%TYPE; --The MIMETYPE of the File
l_nom_document tb_document.nom_document%TYPE; --The name of the file
BEGIN
SELECT blob_document,
mimetype_document,
nom_document
INTO l_blob_content,
l_mime_type,
l_nom_document
FROM tb_document
WHERE pk_document = p_file_id; --SELECT the BLOB file and its information based on the ID from the document table
-- This below creates the download
sys.HTP.init;
sys.OWA_UTIL.mime_header(l_mime_type, FALSE);
sys.HTP.p('Content-Length: ' || DBMS_LOB.getlength(l_blob_content));
sys.HTP.p('Content-Disposition: attachment; filename="' || l_nom_document || '"'); --Create a download with the name of the original file
sys.OWA_UTIL.http_header_close; --If you remove "attachment;", the file will not be downloaded automatically, but opened in a new Tab
sys.WPG_DOCLOAD.download_file(l_blob_content); --File is downloaded
apex_application.stop_apex_engine;
EXCEPTION
WHEN apex_application.e_stop_apex_engine THEN
NULL;
WHEN OTHERS THEN
HTP.p('Whoops');
END;
/
2。创建应用程序项
- 姓名: FILE_ID
- 范围:应用
3。创建申请流程
- 序列: 1
- 处理点: Ajax回调:运行页面进程请求时此应用程序进程
- PL/SQL代码:
BEGIN
GET_FILE(:FILE_ID);
END;
4.转到您的卡片区域所在的页面
5.使用以下设置配置您的操作:
- 身份证 > 类型:全卡
- Link > 类型: 重定向到 URL
- Link > 目标:
f?p=&APP_ID.:0:&APP_SESSION.:APPLICATION_PROCESS=GET_FILE:::FILE_ID:&PK_DOCUMENT.
唯一需要修改的是&PK_DOCUMENT.,比如你的文档table的ID是ID_DOCUMENT,它将是 &ID_DOCUMENT.
您现在可以下载文件了。
现在,如果您想要相同的外观,请按以下步骤操作:
6. SQL查询卡片区域
select PK_DOCUMENT,
NOM_DOCUMENT,
MIMETYPE_DOCUMENT,
CHARSET_DOCUMENT,
BLOB_DOCUMENT,
COMMENT_DOCUMENT,
TAGS_DOCUMENT,
EXTRACT(YEAR FROM TRUNC(CREATION_DOCUMENT)) AS ANNEE, --extract the year from the date
CASE -- if the type of the document is PDF, change the font awesome icon to PDF File
WHEN mimetype_document = 'application/pdf' THEN
'fa fa-file-pdf-o'
-- if the type of the document is Excel, change the font awesome icon to Excel File
WHEN mimetype_document = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
THEN 'fa fa-file-excel-o'
-- if the type of the document is PNG, change the font awesome icon to Image File
WHEN mimetype_document = 'image/png'
THEN 'fa fa-image'
END as ico_document --creates a column just to display the font awesome text
from TB_DOCUMENT
ORDER BY ANNEE DESC; --order the list from most recent to the oldest
7.更改卡片区域的属性
- 名片 > 主键列 1 : [您的 ID 列]
- 标题 > 列: [您的文件名列]
- Body > 列: [您的评论列](例如,提供有关文档的更多信息)
- 图标和徽章 > 图标来源:图标Class列
- 图标和徽章 > 图标列: [ICON_COLUMN 在 [=180= 中的 CASE 语句中创建]查询]
- 图标和徽章 > 徽章位置: [我的“ANNEE”栏,将显示年份]
就是这样! :-)
我正在尝试创建某种“档案”页面,用户可以在其中下载前几年的报告。为此,我首先尝试创建一个 table 来保存我的文档(带有 MIMETYPE、BLOB、FILENAME、CHARSET 列等)。
CREATE TABLE tb_document
(
pk_document NUMBER,
nom_document VARCHAR2(4000),
mimetype_document VARCHAR2(512),
charset_document VARCHAR2(512),
blob_document VARCHAR2(512),
comment_document VARCHAR2(4000),
tags_document VARCHAR2(4000),
creation_document TIMESTAMP(6),
PRIMARY KEY(pk_document)
);
上传一些文件后,我有这样的报告:
点击下载图标,我可以成功下载文件。
但是,我不喜欢报告的外观。然后我尝试创建一个卡片区域,它将显示我的文件,这是我所做的,我更喜欢它:
问题是我不再下载 BLOB link,所以我尝试向卡片区域添加一个 action,通过单击它,将重定向到特定的 URL
这引出了我的问题,与 BLOB 下载 link
请随时询问更多详情,提前致谢,
托马斯
我使用此处建议的解决方案进行 blob 下载:"Download Blob" using Interactive Grid
我的(正常)link 正在重定向到第 9000 页(请参阅上面的第 3 点 link)并将我的主行 ID 分配给 P9000_FILE_ID 项目。
工作量很大,但我可以推荐这个解决方案,因为它描述得很好并且工作正常。 虽然我没有尝试使用卡片,但我使用交互式网格来触发它,但只要你的主要 ID 使用带有 link 的解决方案,我认为也应该适用于卡片。
希望以上link对您有所帮助。
我得到了这个结果:
这给了我这些下载:
这是我的做法:
1.在 SQL 命令中创建此过程
CREATE OR REPLACE PROCEDURE get_file (p_file_id IN VARCHAR2) IS --The parameter will be the ID of the file in my document table
l_blob_content tb_document.blob_document%TYPE; --The BLOB FILE
l_mime_type tb_document.mimetype_document%TYPE; --The MIMETYPE of the File
l_nom_document tb_document.nom_document%TYPE; --The name of the file
BEGIN
SELECT blob_document,
mimetype_document,
nom_document
INTO l_blob_content,
l_mime_type,
l_nom_document
FROM tb_document
WHERE pk_document = p_file_id; --SELECT the BLOB file and its information based on the ID from the document table
-- This below creates the download
sys.HTP.init;
sys.OWA_UTIL.mime_header(l_mime_type, FALSE);
sys.HTP.p('Content-Length: ' || DBMS_LOB.getlength(l_blob_content));
sys.HTP.p('Content-Disposition: attachment; filename="' || l_nom_document || '"'); --Create a download with the name of the original file
sys.OWA_UTIL.http_header_close; --If you remove "attachment;", the file will not be downloaded automatically, but opened in a new Tab
sys.WPG_DOCLOAD.download_file(l_blob_content); --File is downloaded
apex_application.stop_apex_engine;
EXCEPTION
WHEN apex_application.e_stop_apex_engine THEN
NULL;
WHEN OTHERS THEN
HTP.p('Whoops');
END;
/
2。创建应用程序项
- 姓名: FILE_ID
- 范围:应用
3。创建申请流程
- 序列: 1
- 处理点: Ajax回调:运行页面进程请求时此应用程序进程
- PL/SQL代码:
BEGIN
GET_FILE(:FILE_ID);
END;
4.转到您的卡片区域所在的页面
5.使用以下设置配置您的操作:
- 身份证 > 类型:全卡
- Link > 类型: 重定向到 URL
- Link > 目标:
f?p=&APP_ID.:0:&APP_SESSION.:APPLICATION_PROCESS=GET_FILE:::FILE_ID:&PK_DOCUMENT.
唯一需要修改的是&PK_DOCUMENT.,比如你的文档table的ID是ID_DOCUMENT,它将是 &ID_DOCUMENT.
您现在可以下载文件了。
现在,如果您想要相同的外观,请按以下步骤操作:
6. SQL查询卡片区域
select PK_DOCUMENT,
NOM_DOCUMENT,
MIMETYPE_DOCUMENT,
CHARSET_DOCUMENT,
BLOB_DOCUMENT,
COMMENT_DOCUMENT,
TAGS_DOCUMENT,
EXTRACT(YEAR FROM TRUNC(CREATION_DOCUMENT)) AS ANNEE, --extract the year from the date
CASE -- if the type of the document is PDF, change the font awesome icon to PDF File
WHEN mimetype_document = 'application/pdf' THEN
'fa fa-file-pdf-o'
-- if the type of the document is Excel, change the font awesome icon to Excel File
WHEN mimetype_document = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
THEN 'fa fa-file-excel-o'
-- if the type of the document is PNG, change the font awesome icon to Image File
WHEN mimetype_document = 'image/png'
THEN 'fa fa-image'
END as ico_document --creates a column just to display the font awesome text
from TB_DOCUMENT
ORDER BY ANNEE DESC; --order the list from most recent to the oldest
7.更改卡片区域的属性
- 名片 > 主键列 1 : [您的 ID 列]
- 标题 > 列: [您的文件名列]
- Body > 列: [您的评论列](例如,提供有关文档的更多信息)
- 图标和徽章 > 图标来源:图标Class列
- 图标和徽章 > 图标列: [ICON_COLUMN 在 [=180= 中的 CASE 语句中创建]查询]
- 图标和徽章 > 徽章位置: [我的“ANNEE”栏,将显示年份]
就是这样! :-)