How to download files from the database file system.

Hello everyone.

I m trying to do a procedure to download a PDF file that is stored in the file system of the server of the database and not inside the database. The established procedure is the following:


create or replace
PROCEDURE PRT_PR_DOWNLOAD_FICH (v_file_name VARCHAR2
)

AS

V_LENGTH number;
Lob_loc Bfile;

BEGIN


Lob_loc: = bfilename ('DIR_OBJ', v_file_name);
V_LENGTH: = dbms_lob.getlength (Lob_loc);

owa_util.mime_header ("application/octet ', False");
HTP.p ("Content-length: ' |") v_length);
HTP.p ('Content-Disposition: attachment; filename = "" | ") SUBSTR (v_file_name, INSTR (v_file_name, ' /') + 1) | '"');
owa_util.http_header_close;
wpg_docload.download_file (Lob_loc);


END PRT_PR_DOWNLOAD_FICH;


This procedure receive the name of the file to download and use the wpg_docload.download_file () function. The DIR_OBJ is a directory with path from the server to the folder that contains the files I want to download.

When I run this procedure I get the error: "Internal Server Error".

Can someone tell me what I am doing wrong and if it is the best way to download a file directly from the database server file system?

Hello Pedro,

Just out of curiosity, I tried your example ;-) It works very well in my environment! (Oracle 10g with OSH and Apex 3.1.2
But: I had to grant READ permissions on my directory object to APEX_PUBLIC_USER!

(1) I created a "test.txt" document in the directory corresponding with my EXPDIR directory object. 'Oracle' user needs read on the file & document permissions!

(2) give APEX_PUBLIC_USER necessary READ rights on the directory object:

grant read on the directory expdir to apex_public_user;

(3) create the procedure:

CREATE OR REPLACE PROCEDURE MATTHIASH. PRT_PR_DOWNLOAD_FICH (v_file_name VARCHAR2)
AS
V_LENGTH number;
Lob_loc Bfile;
BEGIN
Lob_loc: = bfilename ('EXPDIR', v_file_name);
V_LENGTH: = dbms_lob.getlength (Lob_loc);

owa_util.mime_header ("application/octet ', False");
HTP.p ("Content-length: ' |") v_length);
HTP.p ('Content-Disposition: attachment; filename = "" | ") SUBSTR (v_file_name, INSTR (v_file_name, ' /') + 1) | '"');
owa_util.http_header_close;
wpg_docload.download_file (Lob_loc);

EXCEPTION
WHILE OTHERS THEN
HTP.p (substr (dbms_utility.format_error_stack (): dbms_utility.format_error_backtrace (), 1, 4000));
END PRT_PR_DOWNLOAD_FICH;
/

(4) Grant execute rights on APEX_PUBLIC_USER of this procedure:

GRANT EXECUTE ON MATTHIASH. PRT_PR_DOWNLOAD_FICH TO APEX_PUBLIC_USER;

(5) Finally, try if download document works well:

http://: 7777, pls, apex, MATTHIASH. PRT_PR_DOWNLOAD_FICH? v_file_name = test.txt

I would like to know if it works!

HTH
Matthias

Tags: Database

Similar Questions

  • How to download pictures from the camera to a folder

    Camera is Olympus SP590UZ.

    Does not seem to be recognized by Vista when connected.

    How can I download images to a folder on the computer.

    (Must be in a folder for the edition of Photodex ProShow)

    Hi Sean,.

    Thank you to contact Microsoft Community and we will be happy to help you with your concern.

    According to the description, it seems you are trying to download pictures from the camera to the computer.

    It would be great if you could answer this question in order to help you further.

    Do you receive an error message or error code?

    Refer to the steps in the following Microsoft article and check.

    Hardware devices do not work or are not detected in Windows: http://support.microsoft.com/mats/hardware_device_problems/en-us

    How can I get pictures from my camera to my computer? http://Windows.Microsoft.com/en-in/Windows-Vista/how-do-i-get-pictures-from-my-camera-to-my-computer

    Keep us informed on the status of the issue.

    If you have suggestions/questions more related to Windows feel free to post and we will be happy to help you.

  • How to download videos from the internet

    original title: video download

    How can I download videos from internet? I have windows 7 pro and internet explorer 9. Help, please! Thank you!

    Hi, Jane,.

    If you download a program or file from internet, you will need to click on the "Download" button or link that appears on your computer screen. A download box may appear on your screen asking if you want to run the program from the current location or save the program.

    Choose the option "Save". This will allow you to register the program so that you can use it later once the download is complete. Be careful on the file name, it was saved as and the folder in which it is located. If you do not get a pop box asking you these options, don't worry because some internet browsers save the download automatically.

    Click on the program. If you are ready to access the software or program that you have installed on your computer, click Run and the downloaded program should open for you. Many downloaded software will make a shortcut icon on your desktop so that you will have easy access to the program later.

  • How to get information from the database server log?

    Oracle 9.2 UNIX
    We got an error block in the database of production last midnight for 40 minutes and nothing has been treated during this time which delayed our process by lots of night production. Then he disappeared after 40 min. I would like to know what was going on during this time in the database. My question is where can I find an error in the database server? In bdump? Appreciate any ideas.

    Thank you
    S.

    If you have jobs regularly collect statspack report, then it will be easier to troubleshoot. You can just pull the report of the time period.

    A couple of things you can check if there is a problem of storage during the time, as a backup or other work running took all storage OS, so Oracle hung because no space for archiving of newspapers. Usually it will record errors in the alert.log, but if bdump as complete destination, the error will not be recorded.
    Check the activity of the BONE during the time, which is CPU and IO activity. See if you have installed and configured sar
    Check the message of OS file.

  • How to download pictures from the iPhone 5 c in the mac air.

    Could someone please explain to me how do I download photos from my iPhone 5 c on my MacBook Air?

    Hello

    There are several ways of doing > > import photos and videos from your iPhone, iPad, or iPod touch - Apple Support

  • How to download pictures from the camera to the computer as no autoplay option is displayed?

    Separated from this thread.

    No AutoPlay dialog box appears

    Hello, Vivien.

    Welcome to Microsoft Community forum.

    I would be grateful if you can provide us with the following information to help us better understand the issue.

    1. What is the number and model of your computer and the camera?
    2. All device drivers are updated?
    3. It worked before? If yes you did any recent changes (hardware or software) on your computer?

    Please refer to the suggestion provided by Shinmila: replied on March 28, 2010 in the following thread.

    AutoPlay does not not for digital camera

    Note: The discussion in the thread about Windows 7 but not hold good for Windows 8

    Important: This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs.

    For more information about how to back up and restore the registry, click on the number below to view the article in the Microsoft Knowledge Base:

    How to back up and restore the registry in Windows

    Hope it would help. If problem persists always post returns with the required information and the result of the proposed suggestion, we will be happy to help you.

    Thank you.

  • How to download worksheets in the database of the EBS R12

    Hello


    Is there a way to download the worksheets to the EBS R12 of database using its front-end interface web forms?


    Thank you very much

    Hello

    Loading classic is free, but it is not any user for the product support. Conversely, DataLoad Professional package provides unlimited technical support calls.

    Charging stand
    http://www.dataLoad.NET/support/index.html

    Kind regards
    Hussein

  • How to download media from the clouds of the eLibrary EBS R12.2.5

    Hello

    Electronic library had settings change to cloud, difficult to find media of EBS, kindly help

    Concerning

    Kareem

    There is no 12.3.3 release.

    Mean you 12.1.3 or 12.2.3.

    Edelivery.oracle.com you can download the software 12.1.1 or 12.2.5 by searching for the 'Oracle Financials' product.

    Kind regards

    Bashar

  • How to download images from the camera at the top of the Tower

    I just need to upload photos of a family on my counter top party

    Just connect the camera and syncronise it then copy all the images you want and paste it to any folder on the PC.

  • How to retrieve data from the database after the removal of the lines of the VO?

    Hello
    I use Jdeveloper 11.1.2.1.0
    I have a master's degree and a child.

    So according to my use case when a value in the master t changes the corresponding child should be removed.

    but when I change it to any other value I want to cancel the delete operation and retrieve values in children.

    Is it possible to do?


    Kind regards
    Nigel.

    Edited by: Nigel Thomas March 29, 2012 05:07

    Edited by: Nigel Thomas March 29, 2012 05:09

    Check [url http://mjabr.wordpress.com/2011/05/20/perform-deleteundo-delete-without-using-rollback/] recover deleted lines without using rollback

  • How to download pictures from computer to AT300

    How to download pictures from the tablet computer

    the photos are in alphanumeric order and I like to keep in the present order, once downloaded

    Thank you
    Jim

    Related topics in this forum you can talk to Toshiba.
    To be honest, I n t t see and Toshiba here connection

    However, you can connect the tablet to the laptop (I guess it helps a micro USB interface) and could move the files to the new tablet.

    After the images have been moved to the Tablet, you can use a file Android App Manager to have access to the files.

  • How to download files from the file of database system

    Hello everyone.

    I m trying to do a procedure to download a PDF file that is stored in the file system of the server of the database and not inside the database. The established procedure is the following:

    create or replace
    PROCEDURE PRT_PR_DOWNLOAD_FICH (v_file_name VARCHAR2
    )

    AS

    V_LENGTH number;
    Lob_loc Bfile;

    BEGIN

    Lob_loc: = bfilename ('DIR_OBJ', v_file_name);
    V_LENGTH: = dbms_lob.getlength (Lob_loc);

    owa_util.mime_header ("application/octet ', False");
    HTP.p ("Content-length: ' |") v_length);
    HTP.p ('Content-Disposition: attachment; filename = "" | ") SUBSTR (v_file_name, INSTR (v_file_name, ' /') + 1) | '"');
    owa_util.http_header_close;
    wpg_docload.download_file (Lob_loc);

    END PRT_PR_DOWNLOAD_FICH;

    This procedure receive the name of the file to download and use the wpg_docload.download_file () function. The DIR_OBJ is a directory with path from the server to the folder that contains the files I want to download.


    I want to enable users to download PDF files stored in the file system of the database server, opening a backup / open window in the browser when the user clicks a button. When the user click on the button, the procedure is called and executed without error but save it / open window does not appear, instead the page it is simply charged, nothing happens.

    Can someone tell me what I am doing wrong and if it is the best way to download a file directly from the database server file system?

    Best regards from Pedro

    Hello

    It would help if you add

    APEX_APPLICATION.g_unrecoverable_error := TRUE;  
    

    as a final line of your procedure?

    BR, Jari

  • When I download programs from the internet, they appear just in the form of collections of files TextEditor. How can I convert them into a program.

    When I download programs from the internet, they appear just in the form of collections of files TextEditor. How can I convert them into a program.

    What kind of programs? When you download from? How do download you them?

  • Download file from the database server, through application server.

    Nice day

    I use Jdeveloper 11.1.2.3.0.

    I have a requirement to download a file that already exists on the database server Directory. Now my current scenario is that user is connected to the application server, and the user has no direct access to the database server.  I drew a diagram of my requirement as:


    DownloadFile.png


    I get a way to do this. Please suggest.


    Best regards,

    Julien

    The session does not expire if you are streaming data from the application to the client. However, you will need to manage the data sent over the network, because it can make the very slow network if you send this amount of data at high speeds on the network and then to the customer. This connection between client and server is the biggest problem, because bandwidth is usually small. Think about downloading software by one side oracle (for example 1 GB), this takes time and is prone to errors.

    We did something similar by transferring the data from the database (in our case, it has been stored in a BLOB) on a dedicated server with a server web apache on it. Then, we send a link to the client, which then uses the link to get the special file server data.

    The advantage is that you don't have to code the transfer of huge files in the application of the adf but can already use ready to use of software (balancing bandwidth and the recovery of a broken download).

    Timo

  • How to free up space in a drive by deleting files hidden from the previous operating system?

    Original title: my vista home c drive now have very low free space.there is some files hidden from the previous operatnig system busy space that are useless.how can I delete these files?

    my laptop is slow due to the very low free space in c drive. How can I remove the unnecessary files from c drive or increase the volume of drive c?

    Download a program like TreeSize Free (http://www.jam-software.com/treesize_free/) to see where the files take up a lot of space.  Be aware that deleting files without knowing what you're doing can cause your system to be unable to restart or cause instability can so be sure you know that you are deleting before you start.  There is no way to extend one hard disk other than to replace it, in which case you need to copy all the files from your old drive to the new.

Maybe you are looking for