⚡ 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 

In Oracle APEX, users often need to download multiple files such as reports, documents, or attachments at the same time. Instead of downloading each file individually, we can improve the experience by combining all selected files into a single ZIP file using an Application Process in Shared Components.

In this blog, we will see how to create an Application Process in Oracle APEX that dynamically collects multiple files, compresses them into a ZIP file, and allows users to download them in one click. This approach makes file downloads faster, more organized, and easier to manage while keeping the application simple and efficient.

Step 1: 

In the Application builder go to the shared component, click on the Application Process under the Application Logic section.

 Step 2: 

A new window will be opened, click on the Create button to create the new application process and enter the application process name (in our case, we named BULK_DOWNLOAD) and select the Ajax Callback from point attribute.



 Step 3: 

In the Application process, copy and paste the PLSQL code to generate and download the zip file.

---- 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.





🔥 Conclusion

Thus in Oracle APEX, multiple files can be downloaded as a single ZIP file using an Application Process. This helps users get all required files in one click instead of downloading them one by one.This method keeps the application simple, efficient, and easy to maintain. It also improves performance, enhances user experience, and provides a smooth and organized way to handle file downloads.


Comments

Popular posts from this blog

🔍 Extending Smart Search Filter for Multiple Regions

💡 Designing Dynamic QuickPicks in Oracle APEX

📌Track Active Tab switch in Region Display Selector without any plugins