Dani3lSun / apex-plugin-dropzone

Oracle APEX Region Plugin - Dropzone
MIT License
72 stars 19 forks source link
oracle oracle-apex-plugin orclapex plsql

Oracle APEX Region Plugin - Dropzone

APEX Community APEX Plugin APEX Built with Love

Dropzone is a region type plugin that allows you to provide nice looking drag’n’drop file uploads. It is based on JS Framework dropzone.js (https://github.com/enyo/dropzone).

Demo Application

https://apex.oracle.com/pls/apex/f?p=APEXPLUGIN

Changelog

2.4.1 - Use wwv_flow.ajax endpoint instead of wwv_flow.show for all AJAX actions

2.4.0 - changed "Normal" upload method to use multipart/form-data requests, no base64 conversion needed + works with all web servers

2.3.0 - min. APEX version now is 5.1 ! / Changed chunked upload to also use base64 f01 array (double chunked mechanism) / delete AJAX call only when file has no error

2.2.4 - Updated Dropzone framework to 5.5.0

2.2.3 - Fixed displaying of special characters #39 / some server side code improvements

2.2.2 - Updated Dropzone framework to 5.3.0

2.2.1 - server side waiting: use custom procedure instead of APEX_UTIL.PAUSE (thus only full seconds are possible)

2.2.0 - APEX 5.2 compatibility / Updated Dropzone framework to 5.3.0 / enable dynamic substitution strings for table or collection name / removed parallel uploads option / changed client side waiting to server side waiting after file gets uploaded, removed waiting attribute, general improvements of js and pl/sql code

2.1.0 - Added client side image resizing (before sending to server) / Added configurable chunk size of chunked file uploads

2.0.4 - Added much more detailed Total Upload Progress

2.0.3 - New Style Grey Dashed Border/Background / Improved deleting Files (No longer via Filename, instead the APEX Collection Seq-ID or PK Value of Custom Table is used)

2.0.2 - Performance Improvements for Chunked File Uploads / Improved Upload Status for Chunked File Uploads / Improved Client Side Debug Logging / Improved Server AJAX Error Handling

2.0.1 - Performance Improvements for Chunked File Uploads / Improved Client Side Debug Logging / Oracle Database EPG Note in Docs & Help Pages

2.0.0 - Complete new Version built from ground up. Now much easier to use and with more features

Upgrade Notes:


Changelog Version 1.XX #### 1.9.6 - fixed issue #15 (Page Items to Submit) / Added new event "Dropzone max files exceeded" (issue #13) *Update Note from v1.9.5: It may be required to renew the PL/SQL Code (Upload) to the default which is shipped with this plugin. Unfortunately Plugin Attributes are not updated automatically.* #### 1.9.5 - fully compatible with APEX 5.1 / Delete files inside Dropzone / General Code Cleanup / New Plugin Events / Float number as max Filesize *Update Note: It may be required to renew the PL/SQL Code (Upload) to the default which is shipped with this plugin. Unfortunately Plugin Attributes are not updated automatically.* #### 1.9.4 - updated dropzone library to 4.3.0 / added a much more detailed upload progress bar per file #### 1.9.3 - solved performance issues when converting larger files from base64 CLOB to BLOB #### 1.9.2 - added a random file id to APEX collection (better identification of file by it´s id) / empty file mime types now set to "application/octet-stream" / code cleanup #### 1.9.1 - added more file preview images / more structured file paths / APEX event triggers on Region (not body) / no global js functions any more, wrapped code in namespace "apexDropzone" / cleaned up js code #### 1.9 - added option to include a custom callback javascript function which get executed on chosen events (added file & upload completed) + added APEX events for added file & upload completed to trigger Dynamic Actions #### 1.8 - added option to select a default dropzone style (1: grey border / 2: blue dashed border) / added option to display file type preview images for common file types / minified css/js files (full files for debug mode) #### 1.7 - solved lots of performance issues (file + base64 data get uploaded to server) / stability improvements #### 1.6 - added number of parallel uploads option (1 or 2 concurrent) / performance improvements (base64 encoding when file was added instead of sending moment) / better error handling #### 1.5 - performance improvements(removed redundant AJAX call) / split the clob into a 30k param array (OHS 32k limit for params) / added callback function to apex.server.plugin that processes the files queue #### 1.4 - added option to refresh a chosen region (with REGION_STATIC_ID) after uploading of all files is complete / Copy&Paste support of images in modern Browsers (like Chrome) #### 1.3 - set default for "max Files" to dropzone default of 256 #### 1.2 - added max files per upload option / added customizable messages for better multilingual support #### 1.1 - added options to limit uploading of declared file types (file endings, mime_types, wildcards) / clear dropzone area after uploading of all files finished #### 1.0 - Initial Release #### Beta - In development

Install

Plugin Settings

The plugin settings are highly customizable and you can change:

Plugin Events

How to use

Get files from APEX Collection

If you use the default Options provided with this Plugin, the files are saved in a APEX collection called DROPZONE_UPLOAD. Select it like that:

SELECT c001    AS filename,
       c002    AS mime_type,
       d001    AS date_created,
       n001    AS file_id,
       blob001 AS file_content
  FROM apex_collections
 WHERE collection_name = 'DROPZONE_UPLOAD';

Inserting uploaded files into your own tables

Although the plugin settings allow you to upload the files directly into your custom table, the default setting of APEX Collection is preferred, as this method provides the flexibility to do custom processing prior to inserting the data into the custom table. A typical use case for this is referencing foreign keys. This is easily accomplished using Dynamic Action with PL/SQL code, as follows, assuming the foreign key ID is stored in page item P1_FK_ID:

DECLARE
  -- get files data from saved apex_collection
  CURSOR l_cur_files IS
    SELECT c001    AS filename,
           c002    AS mime_type,
           d001    AS date_created,
           n001    AS file_id,
           blob001 AS file_content
      FROM apex_collections
     WHERE collection_name = 'DROPZONE_UPLOAD';
BEGIN
  -- loop over files cursor
  FOR l_rec_files IN l_cur_files LOOP
    -- do whatever processing is required prior to the insert into your own table
    INSERT INTO custom_table (
        filename,
        mime_type,
        upload_date,
        file_content,
        fk_id
    ) VALUES (
        l_rec_files.filename,
        l_rec_files.mime_type,
        l_rec_files.date_created,
        l_rec_files.file_content,
        :P1_FK_ID
    );
  END LOOP;
  -- clear original apex collection (only if exist)
  IF apex_collection.collection_exists(p_collection_name => 'DROPZONE_UPLOAD') THEN
    apex_collection.delete_collection(p_collection_name => 'DROPZONE_UPLOAD');
  END IF;
END;

Hint for ORDS and Tomcat users

If you have Problems uploading larger Files (only with prefered Upload Mechanism "Normal"), then it could be a Issue with the max. allowed Post Size of Tomcat Server (default is 2MB). To get around this issue please add the Parameter maxPostSize with a Byte value to your Connector in server.xml file of Tomcat.

For AJP connector:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" address="127.0.0.1" maxPostSize="15728640" />

For HTTP connector:

<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" address="127.0.0.1" maxPostSize="15728640" />

This example sets maxPostSize to 15MB or 15728640 bytes. Setting the maxPostSize attribute to a value less than zero (e.g -1) disables the whole limitation. More about it in the Tomcat 8 Documentation

Preview

Preview Copy&Paste