我正在嘗試創建某種“檔案”頁面,用戶可以在其中下載前幾年的報告。為此,我首先嘗試創建一個表來保存我的檔案(帶有 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 下載鏈接,所以我嘗試向卡片區域添加一個操作,單擊它會重定向到特定的 URL

這引出了我的問題,與 BLOB 下載鏈接執行相同操作的 URL 是什么
,然后如何下載我在卡上單擊的特定檔案?
不要猶豫,詢問更多詳細資訊,提前致謝,
托馬斯
uj5u.com熱心網友回復:
我使用此處建議的解決方案進行 blob 下載:
這給了我這些下載:

這是我的做法:
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. 使用以下設定配置您的操作:
- 身份識別>型別:全卡
- 鏈接>型別:重定向到 URL
- 鏈接>目標:
f?p=&APP_ID.:0:&APP_SESSION.:APPLICATION_PROCESS=GET_FILE:::FILE_ID:&PK_DOCUMENT.
唯一需要修改的是&PK_DOCUMENT。例如,如果您的檔案表的 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 : [YOUR ID COLUMN]
- 標題>列: [您的檔案名列]
- Body > Column : [YOUR COMMENT COLUMN](例如,提供有關檔案的更多資訊)
- 圖示和徽章>圖示來源:圖示類列
- 圖示和徽章>圖示列: [在 SQL 查詢中的 CASE 陳述句中創建的 ICON_COLUMN]
- 圖示和徽章>徽章位置: [我的“安妮”列,將顯示年份]
就這樣 !:-)
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/360992.html
標籤:甲骨文 文件 下载 斑点 oracle-apex
上一篇:Androidfile.exists()和file.isFile不起作用
下一篇:如何在c 中獲得相同的行
