⚡ One Click Download: Multiple Files as ZIP in Oracle APEX (No Plugin Needed!)
🚩Introduction
In Oracle APEX applications, users often need to download multiple files at once, such as reports, documents, or attachments. Instead of downloading each file individually, we can improve the user experience by combining all selected files into a single ZIP file.
Using an Application Process in Shared Components along with PL/SQL, we can dynamically collect multiple files and generate a ZIP file for download. This approach removes the need for external tools or plugins and makes file handling easier, faster, and more efficient within the APEX environment.
📑 Why This Approach Is Needed
In Oracle APEX applications, users often need to download multiple files at once, such as reports, images, or documents. Downloading files one by one can be time-consuming and inconvenient, especially when dealing with large numbers of files.
Creating a ZIP file using an Application Process in Shared Components is useful when:
- You want to avoid multiple individual downloads
Users need a single file containing all required documents
The application should provide a smooth and faster download experience
File handling should be managed within APEX without external tools
Performance and user convenience are important
- The solution should remain simple and easy to maintain
This approach improves usability, reduces download effort, and provides an efficient way to manage multiple file downloads using built-in Oracle APEX features.
👉 Use Case: Download Multiple Files as ZIP Using Application Process
Step 1:

Step 2:

Step 3:
---- PLSQL Code to Download Multiple Files as ZIP ----
DECLARE l_zip_blob BLOB; BEGIN -- Create temporary ZIP BLOB DBMS_LOB.CREATETEMPORARY(l_zip_blob, TRUE);
-- Add files to ZIP FOR r IN ( SELECT attachment_name, attachment FROM attachments -- Replace with your table which holds the blob file
ORDER BY id ) LOOP APEX_ZIP.ADD_FILE( p_zipped_blob => l_zip_blob, p_file_name => r.attachment_name, p_content => r.attachment ); END LOOP; -- Finalize ZIP APEX_ZIP.FINISH(l_zip_blob);
-- Send ZIP to browser OWA_UTIL.mime_header('application/zip', FALSE);
HTP.p('Content-Length: ' || DBMS_LOB.getlength(l_zip_blob));
HTP.p('Content-Disposition: attachment; filename="files.zip"'); -- Replace the file name
OWA_UTIL.http_header_close;
WPG_DOCLOAD.download_file(l_zip_blob);
-- Stop APEX engine APEX_APPLICATION.stop_apex_engine; END;
Step 4:
In the page designer, create one button and under the Behaviour section, select the Submit Page from the Action attribute.
Step 5:
Click on the Processing Tab and Create one Branch Process. Under the Exection section, select the Execution Point as After Processing. Under the Behaviour section, select the type as Page or Redirect to URL and click on the Target Button, it will open a new window.
Step 6:
Enter the 0 in the page attribute and under the Advanced section, enter the APPLICATION_PROCESS = BULK DOWNLOAD in the Request Attribute.
APPLICATION PROCESS = BULK DOWNLOAD
Step 7:
Now save and run the page, you will see the button rendered in the page, on clicking that button the zip will be downloaded container all the files.







Comments
Post a Comment