Forum Stats

  • 3,767,858 Users
  • 2,252,726 Discussions
  • 7,874,366 Comments

Discussions

Solution for File Upload / Download without Webutil or Javabean for Webforms

RajeshAlex
RajeshAlex Member Posts: 105 Red Ribbon
edited Oct 5, 2021 11:46AM in Forms

Recently worked on an interesting requirement where client does not want to implement webutil or java bean for the forms on the web. However they wanted users to copy and upload contents of a flat file/csv to the server. These file sizes are smaller around 30K.

Solution was to create a multi line text item with max size of 32676. Then using the plsql utl_text io create a file on the database server (Directory). Then using the external table read the file and insert to table.

If the file size is more than 32KB, then the user has to split the file into multiple chunks. This method worked faster than the typical webutil/ file upload bean.

And the reverse is also possible. Another client requirement was to download a file from the database server without using webutil. In this case we read the file using the external table and created a report with output format as csv/txt file. From the forms used web.show_document.

Much faster than the webutil/java bean.


Just sharing my 2 cents.


Thank you

RajeshAlex

Comments

  • Michael Ferrante-Oracle
    Michael Ferrante-Oracle Senior Principal Product Manager USMember Posts: 6,889 Employee

    Interesting idea, but I'm not sure what was solved here. You said,

    ...does not want to implement webutil or java bean for the forms on the web. However they wanted users to copy and upload contents of a flat file/csv to the server...

    WebUtil is only needed when you want client side (external to the form) interaction. If the user is simply going to manually copy/paste 30k of text into a Forms text field this is something that was always possible. Further, if you want the output file to end up on the mid-tier server, you could just use TEXT_IO to write the file on the mid-tier and not use DB resources to do it.

    Similar is true in reverse. If you want to view that 30k of text on the user machine, you can use TEXT_IO to read the file and display its contents in a text item.

    Again, WebUtil or a Bean is only needed if you wanted to reach out beyond the boundaries of the application on the user machine and do something like directly access a user file.

  • RajeshAlex
    RajeshAlex Member Posts: 105 Red Ribbon

    Thanks Mike. I have seen many clients does not want to implement the Webutil/java due to security concerns.

    This option was there for long time. However no one seems to have explored it. Many developers think about webutil/java bean when file transfer requirement comes. This requirement was very specific where webutil or java can not be used and they want to transfer the file.


    Best Regards

    Rajesh Alex

  • Michael Ferrante-Oracle
    Michael Ferrante-Oracle Senior Principal Product Manager USMember Posts: 6,889 Employee

    I understand what you are saying, but there is no reason to make the DB do the work. The file can be created on the mid-tier using TEXT_IO in Forms. Then if the file is needed on the user machine, the app can use WEB.SHOW_DOCUMENT to retrieve it. The entire process can be performed without even having a DB connection.

  • RajeshAlex
    RajeshAlex Member Posts: 105 Red Ribbon

    I uploaded to the database because this requirement was to populate the data to a table, do some validations and aggregations and insert to other tables.

    If I use text_io, the file gets uploaded to the apps server and then I need to use text io read the lines which is slow and then I need to code the validations separately for each line and column. Hence I used the external table to load the data to a table and then insert to other tables which is pretty fast.