“下载Blob"使用交互式网格

编程入门 行业动态 更新时间:2024-10-26 03:37:42
本文介绍了“下载Blob"使用交互式网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

什么等同于交互式网格的交互式报告下载Blob"?

What is equivalent to the Interactive Report "Download Blob" for Interactive Grids?

当前,我正在使用交互式报表"作为解决方法,但我想使用交互式网格",但是没有下载Blob"列类型,并且我不想在select子句中入侵URL.

Currently I am using an Interactive Report as my workaround but would like to use Interactive Grid however there is no Download Blob column type and I don't want to hack a URL in the select clause.

推荐答案

以下是一些步骤,向您展示如何在APEX 19.2中完成它.可以根据您的业务需求随意调整其他版本的APEX.

Here are some steps that show you how it's done in APEX 19.2. Feel free to adjust as needed for other versions of APEX and as per your business requirements.

  • 创建一个表来存储BLOB文件并添加一个文件作为示例.

  • Create a table to store BLOB files and add a file as an example. create table files ( id number generated by default as identity, mime_type varchar2(255), name varchar2(255), content blob, constraint files_pk primary key (id) ) / insert into files ( mime_type, name, content ) values ( 'text/plain', 'test.txt', hextoraw('48656c6c6f20576f726c6421') ); commit;

  • 使用此查询在表上创建一个新的Interactive Grid页面:

  • Create a new Interactive Grid page on the table using this query:

    select id, mime_type, name, dbms_lob.getlength(content) file_size from files

  • 在应用程序中创建一个新的空白页.将页码设置为9000,并将名称设置为下载文件.

  • Create a new Blank Page in your application. Set Page Number to 9000 and set Name to Download File.

    在页面设计器的左列中,右键单击内容正文(在区域下),然后选择创建区域 >.右键单击新区域,然后选择创建页面项.将新项目的名称设置为P9000_FILE_ID,并将类型设置为隐藏".请注意,该区域或其项目都不会显示.

    In the left-hand column of the Page Designer, right-click Content Body (under Regions) and select Create Region. Right-click the new region and select Create Page Item. Set the Name of the new item to P9000_FILE_ID and set the Type to Hidden. Note that neither the region or its item will ever be displayed.

    在页面设计器的左列中,打开预渲染部分,右键单击标题前,然后选择创建处理.将过程的名称设置为下载文件",然后为 PL/SQL代码输入以下代码:

    In the left-hand column of the Page Designer, open the Pre-Rendering section, right-click Before Header, then select Create Process. Set the Name of the process to Download File and enter the following code for the PL/SQL Code:

    declare l_files_rec files%rowtype; begin select * into l_files_rec from files where id = :P9000_FILE_ID; owa_util.mime_header(l_files_rec.mime_type, false); htp.p('Content-Length: ' || dbms_lob.getlength(l_files_rec.content)); htp.p('Content-Disposition: attachment; filename="' || l_files_rec.name || '"'); owa_util.http_header_close; wpg_docload.download_file(l_files_rec.content); apex_application.stop_apex_engine; end;

    此PL/SQL代码是从数据库获取文件并将其流式传输到浏览器的功能.例如,您可能需要修改此代码,以确保用户应有权访问他们尝试下载的文件.另外,请考虑应用程序和页面级别的安全性.

    This PL/SQL code is what gets the file from the database and streams it to the browser. You may want to modify this code, for example, to ensure a user should have access to the file they are trying to download. Also, consider application and page level security.

    在页面设计器中,返回到交互式网格"页面.右键单击交互式网格"区域下的列,然后选择创建列.将列名设置为下载,将类型设置为链接,并且(在源下)将类型设置为无.点击目标的未定义链接按钮以打开链接设置.将 Page 设置为9000,使用弹出窗口选择 Name 列下的P9000_FILE_ID,使用弹出窗口选择 Value 列下的ID同一行),然后单击确定按钮.最后,设置链接文本(在 Target 下)以下载.

    In the Page Designer, return to the Interactive Grid page. Right-click Columns under the Interactive Grid region and select Create Column. Set Column Name to Download, Type to Link, and (under Source) set Type to None. Click the No Link Defined button for Target to open the link settings. Set Page to 9000, use the popup to select P9000_FILE_ID under the Name column, use the popup to select ID under the Value column (in the same row), then click the OK button. Finally, set Link Text (under Target) to download.

    要测试,请运行页面并单击下载链接.浏览器应该下载文件,并且当您打开文件时,其内容应该是:Hello World!

    To test, run the page and click the download link. The browser should download the file and when you open it the contents should be: Hello World!

  • 更多推荐

    “下载Blob"使用交互式网格

    本文发布于:2023-06-06 05:54:41,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/534733.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:网格   Blob   quot

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!