Apex_Application_Files (WWV_FLOW_FILES) in Apex 3.0.1

Hello,
We are currently using 3.0.1 of Apex and have been using the Apex_Application_Files view to upload files from Apex.
What I don't understand is, when looking at the details of this view I notice that NAME is VARCHAR2(90) and the FILENAME is VARCHAR2(400) and what I am wondering is can I ever get a filename that will be over 80 odd characters?
As I have been looking at my data and I notice that the values in the NAME field seem to be F(some random number)/filename so that is why I am asking if my filename should be no more than 80 characters?
I have tried uploading a file with a filename of 90 characters and all I am getting a 404 Page not found, The requested URL /pls/htmldb/wwv_flow.accept was not found on this server.
I have tried putting a validation of checking the length of the filename but that is not even getting called.
Cheers,
Paul.

Here is a good post on how to use JavaScript to test the name before the page is posted. http://www.oracleapplicationexpress.com/2009/04/file-browse-filename-length-limit.html
I think the page validations get called after the internal Apex process tries to load the file data.
Greg

Similar Messages

  • APEX BFILE

    I have to store graphical documents in an Oracle Database using Apex. I have designed an application based on the Sample Application for Customers, Product, Orders Page 3 and 6 using apex_util.get_blob_file_src and a File Browse Item to store the document in a BLOB field. That works perfectly.
    Now I had to change the application to store the BLOB content in a file and set a pointer in a BFILE column leaving the BLOB column empty. Therefore I wrote a view converting BFILE to BLOB and some instead of triggers to convert BLOB to BFILE.
    Then I rewrote my Apex pages using the view instead of the table. It doesn’t work. I noticed that when using the table Apex is first executing an INSERT leaving the BLOB empty and after that an UPDATE to fill the BLOB column when creating a new record. When using the view instead of the table the INSERT is executed but not the UPDATE.
    So I wanted to write a page process to update the table manually. But I found that there was no entry in the view APEX_APPLICATION_FILES generated by Apex. So I have no chance to obtain the BLOB value and use it to update my table.
    What can I do to have the BLOB content written by Apex to the table the view APEX_APPLICATION_FILES is selecting from?

    Hi
    WWV_FLOW_FILES uses APEX security mechanisms - so you cannot see any entry when selecting it
    from e.g. SQL*Plus. If you want to check the entries you need to use SQL Workshop.
    If you create a File Browse Item named P1_FILE you can select the BLOB content with
    declare
    v_lob blob;
    begin
    -- get uploaded content
    select CLOB_CONTENT into v_lob from wwv_flow_files where name = :P1_FILE;
    -- insert into own table
    insert into ...
    -- remove from WWV_FLOW_FILES after copying
    delete from wwv_flow_files where name = :P1_FILE;
    end;
    Note that you cannot insert into a BFILE - your target table column must be of the type BLOB
    Regards
    -Carsten

  • Please help, I need to read blob and output in bytes from wwv_flow_files.

    Hi all,
    I am having a requirement to read a blob stored in the oracle table and convert it into bytes. I am loading this table (wwv_flow_files) with APEX.
    The code under page 1 is as follows:
    DECLARE
    z number;
    y varchar2(4000);
    x varchar2(400);
    b blob;
    BEGIN
    select filename,blob_content into x ,b from APEX_APPLICATION_files where name =:P1_FILE_NAME;
    select length(convertBlobToBytes(b)) into z from dual;
    :P1_RESULT := z;
    end;
    Java code is as follows:
    import java.io.*;
    import java.sql.Blob;
    public class convertBlob {
    * @param blob
    * @return
    public static byte[] convertBlobToBytes(Blob blob) {
    if (blob==null) return null;
    try {
    InputStream in = blob.getBinaryStream();
    int len = (int) blob.length(); //read as long
    long pos = 1; //indexing starts from 1
    byte[] bytes = blob.getBytes(pos, len);
    in.close();
    return bytes;
    catch (Exception e) {
    System.out.println(e.getMessage());
    return null;
    PL/SQL wrapper is as follows:
    CREATE OR REPLACE FUNCTION convertBlobToBytes(p1 IN BLOB) RETURN LONG RAW AUTHID CURRENT_USER AS LANGUAGE JAVA NAME 'convertBlob.convertBlobToBytes(java.sql.Blob) return byte[]';
    I loaded this java class and pl/sql wrapper into the database using JDEVELOPER.
    But I am getting the length of the file, as twice the size.
    For example, When I run the program which reads the file returns the length of the file as a byte array, the length is 819.
    When I pass the same file as a blob from apex, to the java program that converts blob to bytes, the length of the file is 1638.
    And hence I am getting wrong results, further in the process.
    Can you please help me? Any help is appreciated.
    rgds,
    Suma.

    The example on this page is showing how to read a blob in portions you determine yourself:
    http://apex.oracle.com/pls/otn/f?p=31517:91
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://apex.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • File Browse Validation not stopping upload

    Hi Guys,
    I am using Apex 4.0 and need help with the following please:
    I have a file browse item which uploads a file into the built in WWV_FLOW_FILES. The problem is it uploads even when there is an error and my validation flags up.
    Is it supposed to, does anyone no a work around? Basically I dont want the end user to upload the same file more than once.
    Thanks in advance all
    Spam

    I have a file browse item which uploads a file into the built in WWV_FLOW_FILES. The problem is it uploads even when there is an error and my validation flags up. Is it supposed to...Yes. The file data is just the same as any other form value, and has to be submitted and held in session state (in this case in <tt>APEX_APPLICATION_FILES</tt>) before APEX can do anything with it:
    {thread:id=902770}
    Basically I dont want the end user to upload the same file more than once.You'll have to perform some kind of validation check for this and if it fails, delete the unwanted file:
    {thread:id=1772863}

  • Plesae help- needing to read a blob from db into bytes[]

    Hi all,
    I am having a requirement to read a blob stored in the oracle table and convert it into bytes. I am loading this table (wwv_flow_files) with APEX.
    The code under page 1 is as follows:
    DECLARE
    z number;
    y varchar2(4000);
    x varchar2(400);
    b blob;
    BEGIN
    select filename,blob_content into x ,b from APEX_APPLICATION_files where name =:P1_FILE_NAME;
    select length(convertBlobToBytes(b)) into z from dual;
    :P1_RESULT := z;
    end;
    Java code is as follows:
    import java.io.*;
    import java.sql.Blob;
    public class convertBlob {
    * @param blob
    * @return
    public static byte[] convertBlobToBytes(Blob blob) {
         if (blob==null) return null;
         try {
         InputStream in = blob.getBinaryStream();
         int len = (int) blob.length(); //read as long     
    long pos = 1; //indexing starts from 1
         byte[] bytes = blob.getBytes(pos, len);           
    in.close();
         return bytes;     
    catch (Exception e) {
         System.out.println(e.getMessage());
         return null;
    PL/SQL wrapper is as follows:
    CREATE OR REPLACE FUNCTION convertBlobToBytes(p1 IN BLOB) RETURN LONG RAW AUTHID CURRENT_USER AS LANGUAGE JAVA NAME 'convertBlob.convertBlobToBytes(java.sql.Blob) return byte[]';
    I loaded this java class and pl/sql wrapper into the database using JDEVELOPER.
    But I am getting the length of the file, as twice the size.
    For example, When I run the program which reads the file returns the length of the file as a byte array, the length is 819.
    When I pass the same file as a blob from apex, to the java program that converts blob to bytes, the length of the file is 1638.
    And hence I am getting wrong results, further in the process.
    Can you please help me? Any help is appreciated.
    rgds,
    Suma.

    Hi all,
    Can any of you please help me out?
    rgds,
    Suma.

  • Using File Browse to update stored file

    Hi all,
    I have a form with a File Browse item on it which is (surprisingly!) used to upload a file and associate with a record. The filename is stored in a varchar column in the table. This works fine when I create (INSERT) the initial record and I can retrieve the stored file just fine. However the problem I have is when I want to update the uploaded file. It seems the normal mechanisms for update / save requests don't apply to uploaded files. My other attributes get updated fine but the new uploaded filename is not reflected in the table.
    I've put together a simple example of this on a when apex.oracle.com :
    http://apex.oracle.com/pls/otn/f?p=40740
    Which has two fields, a file name and an 'attribute'. Try as I might I can't update the file name although the attribute changes just fine.
    Any suggestions will be much appreciated. I realise I may be missing something fundamental here and am more than happy to be enlightened.
    FYI, the purpose for such functionality is to allow users of our system to store a photograph of themselves along with their details. This functionality is required to allow the photograph to be updated if required.
    Thanks,
    Steve

    If i am not mistaking, using a file browser item type will not set the uploaded file (blob) in this item, to be processed in the standard processing on you're page.
    In a recent project i wrote a stored procedure for handling with uploaded files. This procedure, which based on the filename ( Fnnnn/<filename> ) , select the uploaded content through apex_application_files, the location apex saves the files. and procedure outputted the file as a blob, which then can be used to insert/update in youre table
    Hope this example code will help you:
    procedure upload_bestand( p_file_name in varchar2
    , p_file out nocopy blob
    , p_filetype out nocopy varchar2 )
    is
    -- Cursor voor bepalen bestand uit apex_application+files
    cursor c_file ( b_file_name in varchar2)
    is
    select aaf.filename
    , aaf.mime_type
    , aaf.blob_content
    from apex_application_files aaf
    where aaf.name = b_file_name
    r_file c_file%rowtype;
    begin
    open c_file ( b_file_name => p_file_name );
    fetch c_file into r_file;
    if c_file%notfound
    then
    -- Upload van bestand niet geslaagd
    close c_file;
    raise e_file_err;
    end if;
    close c_file;
    -- Geupload bestand uit temp_upload tabel verwijdern
    delete from apex_application_files
    where name = p_file_name
    commit;
    p_file := r_file.blob_content;
    p_filetype := r_file.mime_type;
    end upload_bestand;

  • Adding attachment via File browse not working

    Hi, I'm using Apex 4.1.1 through GlassFish server 3.1.1. Recently I've imported my database application and after running my app, adding of an attachment isn't working anymore. Before I used Apex via Emb. PL/SQL Gateway(from which I've exported app sql) and everything worked just fine. My code for adding attachment is like this:
    IF (:P2_ATTACHMENT IS NOT NULL)
    THEN
    INSERT INTO ATTACHS
    (ID_ATACHMENT,NAME_ATTACH, TYPE_ATTACH, ATTACHMENT, DATE_ATTACH)
    SELECT ID,NAME, mime_type,blob_content, sysdate
    FROM wwv_flow_files
    WHERE NAME = :P2_ATTACHMENT;
    DELETE wwv_flow_files
    WHERE NAME = :P2_ATTACHMENT;
    :P2_ATTACHMENT := NULL;
    END IF;
    If I skip this piece of code, and try to submit page(where is also couple of other insert statements), then is ok.
    What is the problem of this, GlassFish, wwv_flow_files table, apex listener...?
    Thanks.

    Hi,
    >
    isn't working anymore.
    >
    Do you get an error? What diagnostic details do you have? E.g. what do see in View Debug if you run the page in Debug mode?
    Prima facie, there is nothing wrong in the code or in the infrastructure.
    Regards,
    PS: Please post code in &#123;code&#125; tags.
    Edited by: Prabodh on Jun 21, 2012 5:00 PM

  • How to SCAN uploaded files for VIRUS in APEX

    part 1:
    Goal:
    Do a virus scan of the uploaded file from APEX application prior to storing the file in custom tables.
    The process:
    Followed the document from www.developer.com:
    Implementing an Anti-Virus File Scan in JEE Applications
    By Vlad Kofman
    Go to page: 1 2 3 Next
    This article will discuss one of the ways to implement antivirus file scanning in Java, particular in the JEE applications. Viruses, Trojan Horses, and different malware and spyware are a real problem for current computer environments, and especially for the Windows operating system. If you are designing any application in Java that has a requirement to be able to upload external files, you have a potential security risk. By uploading, I mean any way to get the external file inside of the corporate firewall be it via HTTP protocol or any other means. It is quite common to have this type of requirement in an enterprise application and with Java being one of the most popular web development platforms, it is unfortunate that this type of gaping security risk is quite often overlooked.
    Java's Development Kit (JDK) does not have any means to do the antivirus scan right out of the box. This is primarily because Java is a programming language, and does not have any virus scanning packages. Furthermore, anti-virus software is not Sun's area of expertise or business model. Developing this type of software (or Java package), and more importantly maintaining it, would be a huge task for Sun. Mainly because viruses are constantly evolving and keeping virus definitions up-to-date is a daunting task. Large companies such as McAffee, Symantec, or Zone Labs develop virus detecting and combating products and spend a lot of resources to maintain them.
    Application Environment
    To implement a virus file scan in Java, a third-party package needs to be used. For the purposes of this article, I will use Symantec Scan Engine (SSE) package, which comes with Java APIs. This package is an application that serves as a TCP/IP server and has a programming interface and enables Java applications to incorporate support for content scanning technologies. For this article, I used Symantec Scan Engine 5.1, which is available as a Unix or Windows install.
    If you are using an anti-virus package from the different vendor, you will need to investigate what kind of APIs are available; however, the general approach should be similar. Also, note that my implementation can be used with JEE technology and any modern MVC framework such as Struts or Spring.
    The architecture is as follows: A server machine needs to have SSE running at all times. This can be the same machine that hosts your Application Server, but in an enterprise environment this should be a different machine. The Default Port needs to be open through the firewall to allow communication with the scan engine. All JEE applications that need to do file scanning can talk to the SSE server machine through a default port. Also, multiple applications running on different application servers can re-use the same scanning server. For more information, you should refer to the Symantec Scan Engine (SSE) Installation Guide, available on the Symantec web site.
    When an external file that needs to be scanned is sent to the SSE via its programming interface (Java APIs using the default port), before any other operation on the file is performed, the SSE returns a result code. For instance, a file is uploaded by an external user into the web email type application as an attachment; then, the SSE API is invoked by the application and the return code of pass or fail determines the outcome of the upload and whether that email can actually be sent. If you have an account on Yahoo mail, you probably have seen that Yahoo is using Norton Antivirus to scan all attachments, although no Java.
    Click here for a larger image.
    Figure 1: Screen shot from Yahoo
    For details on the Scan Engine Server Installationm please see the Symantec Scan Engine (SSE) Implementation Guide from Symantec.
    Here are some key things to remember about SSE:
    •     Java 2 SE Runtime (JRE) 5.0 Update 6.0 or later must be installed on the server before the SSE installation is done.
    •     After installation, verify that the Symantec Scan Engine daemon is running. At the Unix command prompt (if it's a Unix install), type the following command:
    ps –ea | grep sym.
    A list of processes similar to the following should appear:
    o     5358 ? 0:00 symscan
    o     5359 ? 0:00 symscan
    If nothing is displayed the SSE process did not start.
    If the SSE process did not start, type the following command to restart SSE:
    /etc/init.d/symscan restart
    •     Keeping the virus definition up to date is the most important task and if new updates are not installed, the whole scan becomes ineffective. Symantec automatically downloads the most current file definitions through LiveUpdate. Please make sure that firewall rules are in place to allow the host server to connect to the Symantec update service.
    Project Setup
    For the purposes of this article, I included a wrapper for the Symantec SSE APIs, av.jar, which has Symantec Java APIs and serves as a client to the SSE server and takes care of all communications with the server. Please refer to the download source section. The av.jar should be included in the Java CLASSPATH to work with the SSE. This jar contains a class called AVClient that takes care of actually sending the files to SSE as byte arrays and returning the result.
    In my project setting, I added three variables to be accessed via the System.getProperty mechanism. For example:
    AV_SERVER_HOST=192.168.1.150
    AV_SERVER_PORT=1344
    AV_SERVER_MODE=SCAN
    The AV_SERVER_HOST is the host name or IP of the machine where Scan Engine is installed.
    The AV_SERVER_PORT is the port where Scan Engine listens for incoming files.
    The AV_SERVER_MODE is the scan mode which can be:
    •     NOSCAN: No scanning will be done (any keyword that does not start with "SCAN" will result in ignoring the call to the Scan Engine and no files will be transferred for scanning).
    •     SCAN: Files or the byte stream will be scanned, but the scan engine will not try to repair infections.
    •     SCANREPAIR: Files will be scanned, the scan engine will try to repair infections, but nothing else will be done.
    •     SCANREPAIRDELETE: Files will be scanned, the scan engine will try to repair infections, and irreparable files will be deleted.
    Note: For the file stream (byte array) scanning, the only meaning full values are "SCAN" and "NOSCAN".
    Using the SSE Scanning Java APIs
    In any class where scan is required, call the scanning API provided in the AVClient object located in the av.jar. The AVClient object will establish connection to the Scan Engine server and has the following APIs:
    Figure 2: The significant APIs for the communication with to the Scan Engine Server.
    If scanning a file on the file system, in SCAN only mode, use the call that accepts filename only.
    If scanning a file on the file system, with SCANREPAIR or SCANREPAIRDELETE, use the call that accepts input and output file names.
    If scanning an in-memory file (byte array), use the call accepting byte array.
    For example:
    import com.av.*;
    Initialize setup parameters:
    static String avMode =
    (System.getProperty("AV_SERVER_MODE") != null)
    ? (String) System.getProperty("AV_SERVER_MODE") : "NOSCAN";
    static boolean scan = avMode.startsWith("SCAN");
    static String avServer =
    (String) System.getProperty("AV_SERVER_HOST");
    static int avPort =
    Integer.parseInt( (String) System.getProperty("AV_SERVER_PORT"));
    Scan check example for an in-memory file byte array:
    public void scanFile(byte[] fileBytes, String fileName)
    throws IOException, Exception {
    if (scan) {
    AVClient avc = new AVClient(avServer, avPort, avMode);
    if (avc.scanfile(fileName, fileBytes) == -1) {
    throw new VirusException("WARNING: A virus was detected in
    your attachment: " + fileName + "<br>Please scan
    your system with the latest antivirus software with
    updated virus definitions and try again.");
    Note that if you are using this code inside of the MVC handler, you can throw a custom VirusException and check for it in the calling method and perform any necessary cleanup. I have included the class in the AV Jar as well.
    For example:
    catch (Exception ex) {
    logger.error(ex);
    if (ex instanceof VirusException) {
    // do something here
    else {
    // there was some other error – handle it
    For more details on the Scan Engine Client API, please see Symantec Scan Engine Software Developers Guide.
    Continuation in part2

    part 4:
    c)     Clienttester.java – This is the gui app set to test if the configuration is working or not. This gui uses the method scanfile(inputfile, outputfile) as you can see the result in the outputpane of the jframe.
    * clienttester.java
    * Created on April 12, 2005, 2:37 PM
    * @author george_maculley
    package com.av;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class clienttester
    implements ActionListener {
    // private String ipaddress = "127.0.0.1";
    private String ipaddress = "199.209.150.58";
    //private String ipaddress = "192.168.0.55";
    static JFrame frame;
    JFileChooser chooser = new JFileChooser();
    TextField pathtofile = new TextField(System.getProperty("user.home"), 30);
    // TextField pathtooutfile= new TextField(System.getProperty("user.home"),30);
    private int port = 1344;
    JButton filechooser = new JButton("Browse to file"); ;
    private String originalfilename;
    private String outputfilename;
    JButton scanbutton = new JButton("Scan");
    TextArea outputarea = new TextArea(20, 40);
    TextField iptext = new TextField("127.0.0.1", 16);
    TextField porttext = new TextField("1344", 5);
    AVClient mine;
    JRadioButton choosescan = new JRadioButton("SCAN");
    // JRadioButton choosedelete= new JRadioButton("SCANREPAIRDELETE");
    /** Creates a new instance of gui */
    public clienttester() {
    public clienttester(java.lang.String ip, java.lang.String infile, java.lang.String outfile, int port) {
    this.ipaddress = ip;
    this.port = port;
    this.originalfilename = infile;
    this.outputfilename = outfile;
    boolean setValues(java.lang.String ip, java.lang.String infile, java.lang.String outfile, int port) {
    this.ipaddress = ip;
    this.port = port;
    this.originalfilename = infile;
    this.outputfilename = outfile;
    return (true);
    public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
    JComponent c = (JComponent) actionEvent.getSource();
    if (c == filechooser) {
    int retval = chooser.showDialog(frame, null);
    if (retval == JFileChooser.APPROVE_OPTION) {
    File theFile = chooser.getSelectedFile();
    if (theFile != null) {
    pathtofile.setText(theFile.getPath());
    // pathtooutfile.setText(theFile.getPath());
    JOptionPane.showMessageDialog(frame, "You chose this file: " + theFile.getPath());
    if (c == scanbutton) {
    //return object that can be passed to AVClient
    String policy;
    int thisport;
    int scanresult;
    String thisip;
    String inputfile;
    String outputfile;
    outputarea.append("Server: " + iptext.getText() + "\r\n");
    if (choosescan.isSelected()) {
    policy = "SCAN";
    else {
    policy = "SCANREPAIRDELETE";
    thisport = new Integer(porttext.getText()).intValue();
    thisip = iptext.getText();
    //mine= new AVClient(iptext.getText(),porttext.getText(),policy);
    mine = new AVClient(iptext.getText(), thisport, policy);
    if (mine.test() == 1) {
    outputarea.append("Sorry. Incorrect parameters specified.\r\n");
    System.exit(1);
    else {
    outputarea.append("Connection to SAVSE initialized.\r\n");
    inputfile = pathtofile.getText();
    // outputfile=pathtooutfile.getText();
    outputfile = "/tmp";
    outputarea.append("Scanning file " + inputfile + " \r\n");
    if (policy == "SCAN") {
    scanresult = mine.scanfile(inputfile);
    else {
    scanresult = mine.scanfile(inputfile, outputfile);
    if (scanresult == 0) {
    outputarea.append("File is clean.\r\n");
    else if (scanresult == -1) {
    outputarea.append("File is infected. \r\n");
    else {
    outputarea.append("Scan error.\r\n");
    void display() {
    Frame f = new Frame("SAVSE JAVA ICAP Client");
    f.setLayout(new GridLayout(1, 2));
    JPanel lpanel = new JPanel(new GridLayout(7, 1));
    JPanel ippanel = new JPanel();
    JPanel portpanel = new JPanel();
    JPanel rpanel = new JPanel();
    JPanel outputpanel = new JPanel();
    JPanel buttonpanel = new JPanel();
    JPanel pathpanel = new JPanel();
    // JPanel outpathpanel= new JPanel();
    JPanel policypanel = new JPanel();
    ButtonGroup policygroup = new ButtonGroup();
    filechooser.addActionListener(this);
    scanbutton.addActionListener(this);
    choosescan.setSelected(true);
    policygroup.add(choosescan);
    // policygroup.add(choosedelete);
    buttonpanel.setBorder(BorderFactory.createTitledBorder("Scan Policy"));
    buttonpanel.add(choosescan);
    // buttonpanel.add(choosedelete);
    pathpanel.setBorder(BorderFactory.createTitledBorder("Path to File"));
    pathpanel.add(pathtofile);
    f.setSize(new Dimension(650, 400));
    f.setBackground(Color.white);
    f.setResizable(true);
    ippanel.setBorder(BorderFactory.createTitledBorder("SAVSE IP Address"));
    ippanel.add(iptext);
    outputpanel.setBorder(BorderFactory.createTitledBorder("OUTPUT"));
    outputpanel.add(outputarea);
    portpanel.setBorder(BorderFactory.createTitledBorder("ICAP Port"));
    portpanel.add(porttext);
    // outpathpanel.setBorder(BorderFactory.createTitledBorder("Path to Repair File"));
    // outpathpanel.add(pathtooutfile);
    lpanel.add(ippanel);
    rpanel.add(outputpanel);
    lpanel.add(portpanel);
    lpanel.add(buttonpanel);
    lpanel.add(pathpanel);
    // lpanel.add(outpathpanel);
    lpanel.add(filechooser);
    lpanel.add(scanbutton);
    f.add(lpanel);
    f.add(rpanel);
    f.setVisible(true);
    public static void main(String[] args) {
    clienttester g = new clienttester();
    g.display();
    d)     my2.java – This is the class file I wrote to test that I am able to send a file and scan it and see the output in the JDEVELOPER. In this case the file is stored on the filesystem of the client machine. JDEVELOPER should be able to see the file.
    NOTE:
    “EICAR.com” is the test file downloaded from Symantec site to test a non malicious virus file. I n order to be able to test it like this, the Antivirus program running on your machine should be disabled, or else Antivirus will kick in and delete the file. In the first place you will not be able to download the test virus file either with anti virus running on the machine you are downloading to.
    package com.av;
    import java.io.*;
    public class my2 {
    static int my_return = 0;
    * @param fileBytes
    * @param fileName
    * @return
    public static int scanfile(String fileName){
    String avMode = "SCAN";
    boolean scan = avMode.startsWith("SCAN");
    String avServer = "xx";--avserver ip address
    int avPort = 1344;
    int the_return = 0;
    if (scan) {
    AVClient avc = new AVClient(avServer,avPort,avMode);
    the_return = avc.scanfile(fileName);
    if (the_return == -1) {
    return (the_return);
    } else
    return (the_return);
    //my_return = the_return;
    return (the_return);
    public static void main(String[] args) throws Exception {
    System.out.println("Hi there in Main");
    byte[] b1 = new byte[4];
    b1[1] = 68;
    my_return = scanfile("c:\\eicar.com");
    System.out.println(my_return);
    e)     Then finally we have my1.JAVA, which takes the filename, and it’s contents in the bytes form and scans the file. The reason for this method is we are not storing the file on the filesystem, it is read into the memory and only if it is clean, it is put into the database or else notify the user.
    package com.av;
    import java.io.*;
    public class my1 {
    static int my_return = 0;
    static int a_length = 0;
    * @param fileBytes
    * @param fileName
    * @return
    public static int scanfile(String fileName,byte[] fileBytes) throws IOException {
    String avMode = "SCAN";
    boolean scan = avMode.startsWith("SCAN");
    String avServer = "xxx";--avserver’s ip address
    int avPort = 1344;
    int the_return = 0;
    if (scan) {
    AVClient avc = new AVClient(avServer,avPort,avMode);
    // File file = new File(fileName) ;
    //byte[] fBytes = getBytesFromFile(file);
    the_return = avc.scanfile(fileName, fileBytes);
    if (the_return == -1) {
    return (the_return);
    } else
    {return (the_return);}
    my_return = the_return;
    return (the_return);
    // Returns the contents of the file in a byte array.
    * @param file
    * @return
    * @throws IOException
    public static byte[] getBytesFromFile(File file) throws IOException {
    InputStream is = new FileInputStream(file);
    // Get the size of the file
    long length = file.length();
    // You cannot create an array using a long type.
    // It needs to be an int type.
    // Before converting to an int type, check
    // to ensure that file is not larger than Integer.MAX_VALUE.
    if (length > Integer.MAX_VALUE) {
    // File is too large
    // Create the byte array to hold the data
    byte[] bytes = new byte[(int)length];
    // Read in the bytes
    int offset = 0;
    int numRead = 0;
    while (offset < bytes.length
    && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
    offset += numRead;
    // Ensure all the bytes have been read in
    if (offset < bytes.length) {
    throw new IOException("Could not completely read file "+file.getName());
    // Close the input stream and return bytes
    is.close();
    return bytes;
    // public static void main(String[] args) throws Exception {
    //System.out.println("Hi there in Main");
    // File file = new File() ;
    // byte[] b1 = getBytesFromFile(file);
    //System.out.println(b1);
    // my_return = scanfile(,b1);
    //System.out.println(my_return); }
    Finally , you have the exceptions file,
    e) package com.av;
    public class VirusException
    extends Exception {
    public VirusException() {
    super();
    public VirusException(String text) {
    super(text);
    Once you have all these classes, you can use JDEVELOPER , to load these classes into the database: This is as follows:
    Right click on the project, which has all these classes.
    NEW -> deployment profiles -> load java and stored procedures.
    When you are created deployment profile, you have to specify,
    Loadjava options.
    -f, -v (check the check boxes)
    Under privileges:
    -s – specify database schema these classes are loaded into
    -s – create sysnonym check box
    -g – grant to public or any specific users per your policy.
    Under Resolver,
    -r and –o (check the check boxes)
    I accepted the default name storedproc1. Then you right click on the storedproc1.deploy, deploy to whichever database connection you created.
    And then, In order to access this java class we need a pl/sql wrapper as follows:
    create or replace package my1 is
    function mycheck (pfilename in varchar2, psize in number)
    return number;
    end my1;
    create or replace package body my1 is
         function mycheck (pfilename in varchar2, psize in number)
    return number is
    language java
         name 'com.av.my1.scanfile(java.lang.String, byte[]) return int';
         end my1;
    And the code is invoked from sql plus as follows:
    Select my1.mycheck(“filename”, “filebytes”) from dual;
    One important catch in the above method is to send the filename and filecontents in bytes form. In order to send the file contents as filebytes, you will need another java class and load into the data base as described above.
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    * This program demonstrates how to read a file into a byte array. This method
    * reads the entire contents of the file into a byte array.
    * @version 1.0
    * @author Jeffrey M. Hunter ([email protected])
    * @author http://www.idevelopment.info
    public class ReadFileIntoByteArray {
    * method to convert a byte to a hex string.
    * @param data the byte to convert
    * @return String the converted byte
    public static String byteToHex(byte data) {
    StringBuffer buf = new StringBuffer();
    buf.append(toHexChar((data >>> 4) & 0x0F));
    buf.append(toHexChar(data & 0x0F));
    return buf.toString();
    * Convenience method to convert an int to a hex char.
    * @param i the int to convert
    * @return char the converted char
    public static char toHexChar(int i) {
    if ((0 <= i) && (i <= 9)) {
    return (char) ('0' + i);
    } else {
    return (char) ('a' + (i - 10));
    * Returns the contents of the file in a byte array
    * @param file File this method should read
    * @return byte[] Returns a byte[] array of the contents of the file
    private static byte[] getBytesFromFile(File file) throws IOException {
    InputStream is = new FileInputStream(file);
    System.out.println("\nDEBUG: FileInputStream is " + file);
    // Get the size of the file
    long length = file.length();
    System.out.println("DEBUG: Length of " + file + " is " + length + "\n");
    * You cannot create an array using a long type. It needs to be an int
    * type. Before converting to an int type, check to ensure that file is
    * not loarger than Integer.MAX_VALUE;
    if (length > Integer.MAX_VALUE) {
    System.out.println("File is too large to process");
    return null;
    // Create the byte array to hold the data
    byte[] bytes = new byte[(int)length];
    // Read in the bytes
    int offset = 0;
    int numRead = 0;
    while ( (offset < bytes.length)
    ( (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) ) {
    offset += numRead;
    // Ensure all the bytes have been read in
    if (offset < bytes.length) {
    throw new IOException("Could not completely read file " + file.getName());
    is.close();
    return bytes;
    * @param filename
    public static byte[] chk_file(String filename) {
    byte[] fileArray = null;
    try {
    fileArray = getBytesFromFile(new File( filename));
    } catch (IOException e) {
    e.printStackTrace();
    if (fileArray != null) {
    for (int i=0; i<fileArray.length; i++) {
    System.out.println(
    "fileArray[" + i + "] = " +
    ((int)fileArray[i] < 9 ? " " : "") +
    ( ((int)fileArray[i] > 9 && (int)fileArray[i] <= 99) ? " " : "") +
    fileArray[i] + " : " +
    " HEX=(0x" + byteToHex(fileArray) + ") : " +
    " charValue=(" + (char)fileArray[i] + ")");
    return fileArray;
    * Sole entry point to the class and application.
    * @param args Array of String arguments.
    public static void main(String[] args) {
    byte[] fileArray = null;
    try {
    fileArray = getBytesFromFile(new File("c:\\eicar.com"));
    } catch (IOException e) {
    e.printStackTrace();
    if (fileArray != null) {
    for (int i=0; i<fileArray.length; i++) {
    System.out.println(
    "fileArray[" + i + "] = " +
    ((int)fileArray[i] < 9 ? " " : "") +
    ( ((int)fileArray[i] > 9 && (int)fileArray[i] <= 99) ? " " : "") +
    fileArray[i] + " : " +
    " HEX=(0x" + byteToHex(fileArray[i]) + ") : " +
    " charValue=(" + (char)fileArray[i] + ")");
    Having main method helps you to run the file in JDEVELOPER or using JAVA.
    DO not forget to load this class into the database.
    And you create the pl/sql wrapper again as follows:
    create or replace FUNCTION TOBY (pfilename in varchar2) RETURN VARCHAR2 iS
    language java name
    'ReadFileIntoByteArray.chk_file(java.lang.String) return byte[]';
    And you call the function from sqlplus as follows:
    Sql>Set serveroutput on size 20000;
    Sql> call dbms_java.set_output(20000);
    Sql> Select toby(“filename”) from dual; --
    this file should be accessible, I mean you will not be able to send a file on your pc, from sql plus as sql/plus is running on your db server.
    You will be able to see the output in sql plus:
    If you are running it from the APEX:
    When we use file browser widget from APEX, the file is stored in APEX_APPLICATION_FILES table. And we retrieve that into a variable and pass this variable to the function as follows:
    DECLARE
    scan_failed EXCEPTION;
    x varchar2(400);
    z number;
    BEGIN
    select filename into x from wwv_flow_files where name = :P1_FILE_NAME;
    select my1.mycheck(x,toby(x)) into z from dual;
    if z = 0 then
    :P1_SUBJECT:= 'PASSED';
    else
    :P1_SUBJECT:= 'FAILED';
    end if;
    :P1_SCAN_RESULT := '** Scanning File **';
    IF UPPER(:P1_SUBJECT) = 'PASSED' THEN
    BEGIN
    :P1_SCAN_FLAG := 'PASSED';
    :P1_SCAN_RESULT := :P1_SCAN_RESULT || ' ** File passed scan **';
    END;
    ELSIF UPPER(:P1_SUBJECT) = 'FAILED' THEN
    BEGIN
    :P1_SCAN_FLAG := 'FAILED';
    :P1_SCAN_RESULT := :P1_SCAN_RESULT || ' ** File failed scan **';
    END;
    ELSE
    BEGIN
    :P1_SCAN_FLAG := 'UNKNOWN';
    :P1_SCAN_RESULT := :P1_SCAN_RESULT || ' ** Scan Is Not Conclussive **';
    END;
    END IF;
    --IF :P1_SCAN_FLAG = 'FAILED'
    -- THEN RAISE scan_failed;
    --END IF;
    EXCEPTION
    WHEN OTHERS THEN
    DELETE from APEX_APPLICATION_FILES WHERE name = :P1_FILE_NAME;
    RAISE_APPLICATION_ERROR (-20000, 'seb OTHERS error encountered - file upload not allowed. Possible virus detected !');
    raise;
    END;
    ACKNOWLEDMENTS:
    1) JOHN SCOTT – who suggested this ICAP API in one of the threads which is my initial starting point in this direction.
    2) VLAD KOFMAN who wrote the article on WWW.DEVELOPER.com
    3) Mr. KIRAN –One of the engineers from Metalink, who helped me at every step of getting this java programs and pl/sql wrappers working. But for him, I would have not completed my project.

  • File upload to sftp server using apex

    We have an SFTP server on Linux and we want to provide users with web-based interface (Oracle APEX has been chosen for that purpose) so they can upload their flat files to our sftp server via secure transmission. is it possible to implement on APEX? What might be possible solution? or any workarouds?
    Thanks in advance.

    Hello Kevin,
    >
    if I got it right, in such a case files have to be stored in database directory, as far as I know APEX only allows to store files in database tables. is there any way to put files to a directory without storing them in tables? For instance, I want files to be placed in some oracle directory when users choose files with FILE BROWSE item and then submit the page.
    >
    Yes APEX stores files to tables, but there is a way to store them to OS directory.
    I don't know much about the plugin SaveToDisk:
    http://apex-plugin.com/oracle-apex-plugins/process-type-plugin/savetodisk_167.html
    but i have tried a blog solution by Håvard Kristiansen and it works fine:
    http://monkeyonoracle.blogspot.in/2009/10/storing-images-outside-oracle-xe-with.html
    He has given this solution to store images outside Oracle XE i.e. to a server directory.
    I had done this way:
    1) User uploads a file through file browse.
    2) The file is stored to APEX_APPLICATION_FILES or WWV_FLOW_FILES.
    3) The file is written to the OS directory using the write_to_file procedure mentioned in the blog.
    Hope it helps!
    Regards,
    Kiran

  • File not showing in wwv_flow_files

    After upgrading to APEX 4, my file browse items aren't being written to the wwv_flow_files anymore.
    In my Page process, the code below is returning 'No data Found' errors.
    DECLARE
    p_owner varchar2(30) := '#OWNER#';
    p_user varchar2(30) := :APP_USER;
    p_file_name varchar2(30) := :P1110_FILENAME;
    BEGIN
    select blob_content into v_blob_data from wwv_flow_files
    where filename = p_file_name;
    END;
    The file is correctly uploaded in the table wwv_flow_file_objects$, but I can't see the file in the wwv_flow_files or apex_application_files views. Is there something that needs to be done?
    Thanks!

    select blob_content into v_blob_data from wwv_flow_files
    where filename = p_file_name;
    {quote}
    Assuming <tt>P1110_FILENAME</tt> is a File Browse item, shouldn't that be <tt>www_flow_files/apex_application_files.<strong>name</strong></tt> rather than <tt>filename</tt>? The <tt>name</tt> column contains a unique file reference component that also exists in the File Browse item.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Full path and filename in wwv_flow_files after upload from UNC path in IE

    I have a page with a file browse item. After page submit I move the file from wwv_flow_files to another table.
    Normally the column wwv_flow_files.filename only contains the filename. However, when using IE9 and selecting a file from an UNC path the column contains the full path+filename.
    Does anybody have an idea what happens here?
    How can I make sure I only get the filename?
    Using Apex 4.02.007
    Edited by: Rene W. on Feb 28, 2013 6:39 AM

    Rene W. wrote:
    I have a page with a file browse item. After page submit I move the file from wwv_flow_files to another table.
    Normally the column wwv_flow_files.filename only contains the filename. However, when using IE9 and selecting a file from an UNC path the column contains the full path+filename.
    Does anybody have an idea what happens here?
    How can I make sure I only get the filename?For security/privacy reasons recent versions of browsers by default do not send local file path information from File Browse items to the server, nor expose the file path in the control's JavaScript methods. Firefox, Safari and Chrome only provide the filename. IE6 & IE7 still yield the path in Windows format. IE8+ and Opera have adopted an irritating approach of replacing the path with a wholly imaginary "C:\fakepath\"—and this monstrosity has sadly had to be enshrined in the HTML spec. A reasonably compatible way to strip the path in JS is provided there, or you should be able to do it fairly easily in PL/SQL when moving the file.
    The fact you are getting the full path suggests that the IE security config setting "Include local directory path when uploading files" (or IE9 equivalent) is used in your browser/environment to enable the path to be exposed in IE. This may be necessary to support dismal legacy applications. Consult whoever is responsible for browser security configuration at your site to see why/if this setting is necessary.

  • APEX_APPLICATION_FILES: ORA-00942: table or view does not exist

    Hello,
    As my first APEX task I am attempting the upload/download demo on http://download.oracle.com/docs/cd/B32472_01/doc/appdev.300/b32469/up_dn_files.htm
    The ultimate goal is to store PDF files in the database.
    In order to complete step 1: To create an application using the Create Application Wizard:
    - I first created a user from SYSTEM called 'myapp'
    - Next I logged into 'myapp' to continue the exercise. (I am wondering if that is where I am going wrong... If so, please clarify)
    - Knowing that I would want to save the upload to a table I created a table with a BLOB
    I did the steps for the upload and ran the application - no errors to there.
    Next I needed to "To create a report on APEX_APPLICATION_FILES:".
    I started the wizard as instructed. When I pasted the SELECT ... FROM APEX_APPLICATION_FILES, I got the table or view does not exist. A quick review of the TABLES tab shows only the tables that I created. Not any of the system tables or views.
    I logged back in as SYSTEM and reviewed the 'rights' given the user 'myapp'. All were checked.
    I knew nothing of Oracle when I installed XE, so I took defaults or whatever the install doc said to do. Is that part of the problem? It is clear that I do not have rights to see that table, but I also do not see the table when logged in as SYSTEM.
    Any insight appreciated,
    Rick

    Thanks for the reply.
    Version is:
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Product
    PL/SQL Release 10.2.0.1.0 - Production
    CORE 10.2.0.1.0 Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Production
    Database      
    NAME     XE
    CREATED     10/13/2006 08:04:21 PM
    RESETLOGS_TIME     10/13/2006 08:04:25 PM
    Install Version 10.2.1015
    Regarding the code links, this one looks like what I need:
    DECLARE
    l_bfile BFILE;
    l_blob BLOB;
    BEGIN
    INSERT INTO tab1 (col1)
    VALUES (empty_blob())
    RETURN col1 INTO l_blob;
    l_bfile := BFILENAME('IMAGES', 'MyImage.gif');
    DBMS_LOB.fileopen(l_bfile, Dbms_Lob.File_Readonly);
    DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
    DBMS_LOB.fileclose(l_bfile);
    COMMIT;
    END;
    Is the 'BFILENAME' function that causes the 'get a filename' dialog box of Windows to open for the user to find which file to upload?
    I'm going off to look for a newer version of APEX, thanks.

  • Uploading multiple files into wwv_flow_files.

    Hi,
    I've been happily using the apex file browse button functionality to upload files into the wwv_flow_files table and moving them over to my app specific tables for some time now.
    I was wondering; Is there a straight forward way of uploading all the files in a specified folder into the wwv_flow_files table in a single process; Rather than having to upload them one at a time?
    Cheers,
    Yog.

    Ok. I've tried creating a new DAD by following the instructions here:
    http://www.oracle-base.com/articles/10g/FileUploadDownloadProcedures10g.php
    I've tried various combinations but my lack of experience is letting me down I think.
    I may not even be on the right tack.
    I'm trying to upload a file to a databse table through some kind of automated process. i.e. bypassing the need for a filebrowse button. Ideally I'd like to be able to pass in a filepath to a procedure and for the file to be uploaded.
    Can anyone help with this???
    Getting desperate.
    Yog

  • How to get all image files from a folder to wwv_flow_files?

    Hi there!
    Is it possible in apex to show, in a report look-a-like, all image filenames from a folder in another machine (i enter in that machine by ip) and insert all files into wwv_flow_files?
    I want to see all files, then pick one and open a image...
    But it can't be by browse item... it has to show all filenames as a list...
    If it is possible, how can i do it?
    Thanks!
    Best regards,
    Luis Pires

    Hi,
    you can connect to the server using UTL_HTTP.
    Then for each files you copy the response into a BLOB to be able to show it or to store it in a table.
    A piece of code :
    begin
       -- initialize the BLOB.
       dbms_lob.createtemporary(l_blob, false);
       -- path to the file
       l_url := 'http://your_server/your_file.jpg';
       -- begin retrieving the target.
       l_req := utl_http.begin_request(l_url);
       -- identify ourselves (some sites serve special pages for particular browsers)
       utl_http.set_header(l_req, 'User-Agent', 'Mozilla/4.0');
       -- start receiving the response.
       l_resp := utl_http.get_response(l_req);
       -- copy the response into the BLOB.
       begin
          loop
             utl_http.read_raw(l_resp, l_raw, 32767);
             dbms_lob.writeappend (l_blob, utl_raw.length(l_raw), l_raw);
          end loop;
          -- stop when exception end_of_body is raised
       exception
          when utl_http.end_of_body then
             utl_http.end_response(l_resp);
       end;
    end;It's a minimal example, you may need authentication, check l_resp.status_code, etc...

  • APEX Listener and EPG - strange behaviour

    Hi
    For some years, I've used EPG for APEX but have struggled with performance particularly as I can have up to 150 student developers using at any one time.
    I do a fair amount of work using ORDImage and have successfully developed APEX applications to upload image files and display full-size and thumbnail images.
    After upgrading to APEX 4.1 (from 4.0), I decided to install APEX Listener standalone.
    Before I did so I checked that my applications still worked in 4.1 and they did.
    However, just installing APEX Listener but not configuring it (yet) has meant that my image display in a report using a procedure based on wpg_docload.download_file( l_ordimage_image.source.localData ) no longer works in EPG - the images are not displayed.
    Configuring APEX Listener and running the same application through that DOES display the images.
    So this part of the application works under APEX Listener but not under EPG.
    My application also allows users to upload images from APEX_APPLICATION_FILES using standard code. Under APEX Listener after uploading, I'm left with a blank page with a wwv_flow.accept URL although the image does indeed upload. Under EPG it works as expected and I get a success confirmation.
    So this part of the application works under EPG but not under APEX Listener.
    Has anyone else come across different behaviour depending on the mode of connection?
    Thanks
    Brian
    [Oracle EE 11gR2, Windows Server 2008R2, APEX 4.1, APEX Listener 1.1.3]

    Hi Brian,
    it sounds like you have both EPG and APEX Listener running on the same machine, so your problem might result from a port conflict. Note that both services use TCP port 8080 as default.
    At least a port conflict would explain the strange behaviour in your case, some things working on one web server and some on the other.
    Some parts of your initial post hint to that direction, e.g.
    However, just installing APEX Listener but not configuring it (yet) has meant that my image display in a report using a procedure based on >wpg_docload.download_file( l_ordimage_image.source.localData ) no longer works in EPG - the images are not displayed.... because the APEX Listener only interfere with the EPG if it is at least running on the same machine as your database and furthermore, if it is unconfigured in terms of ist database connection, a port conflict might be the only way it could cause anything like that.
    However, if you are sure that's not the issue, please check if you see any error in the APEX Listener's log for the following action you performed:
    My application also allows users to upload images from APEX_APPLICATION_FILES using standard code. Under APEX Listener after uploading, I'm left with a blank >page with a wwv_flow.accept URL although the image does indeed uploadIf you actually see just a blank screen, something very bad must have happened and you should see some kind of stack trace there.
    For further investigations, if necessary, it would be helpful to know how you deployed or started your APEX Listener and which JDK version you use.
    For the moment, I still think the port conflict is my best guess.
    You could avoid it by either changing the port for EPG (I'd not recommend that if you have other users still using it) or by changing the port for your APEX Listener.
    -Udo

Maybe you are looking for

  • Tax code is not picked up while doing ERS with T. Code. MRRL

    Hi Experts,       I have got one Scheduling Agreement of certain material and based on goods receipt quantity user is performing ERS with T. Code MRRL. but when we are seeing different invoice documents generated by ERS with T. Code MIR4 for the same

  • Problem burning dvd

    Okay, so our racing season is about to begin, so Im ready to start making videos again.  However, my computer is not cooperating. I don't actually think this is an Encore problem I think its a hardware problem, but I didn't know where else to ask so

  • I do I turn the microphone back on for Skype?

    I accidentally declined the microphone for Skype. When I go into my settings privacy and microphone Skype does not show up. How can I correct this and turn the microphone back on for Skype?

  • IBE: Items Per Page for Display profile at Responsibility level

    Hi, we would like to have different number of items per page for different sites. We thought we would achieve it by setting profile "IBE: Items Per Page for Display" at the responsibility level and have unique responsibilities to access different sit

  • JAXB Unmarshalling question

    I want to create Java objects from an XML file; JAXB sounds like the way to go, from what I've read. One question though: the object I want to create is an existing class. What I'd like to do is have JAXB create objects of the existing class, instead