Skip to content

Conversation

@riderx
Copy link

@riderx riderx commented Oct 29, 2025

Summary

This PR introduces blob handling for Android & iOS webviews, based on the work from PR #5498 and updated to work with the latest main branch.

Whenever a blob:/ URL or normal download is requested to be 'opened', a folder selection is prompted and the file is saved.

This addresses issue #5478

Features

  • Base64 blobs through blob:data... scheme - Handles both known and unknown mime-types
    • Both Android and iOS were opening images (like PNG) in the internal browser, causing users to be stuck on the image requiring manual app closure
  • Blob links through blob:http... scheme
  • Web worker initiated downloads - Partially addressed (browser core limitations may apply)

Implementation Details

iOS

  • Works on iOS 14.5+ (WebKit exposed necessary APIs starting from this version)
  • When a download request is received, prompts for folder selection and saves the file with a unique filename
  • Includes compiler guards for Xcode 12 compatibility

Android

  • Implements JS interface that injects JS code to download the received URL through XHR
  • Uses the JS accessible context to pipe content in chunks to an Intent for file selection
  • Implements duplex stream for piping received content to file

Common

  • Both platforms ask users for destination selection
  • Implement download notifications to be consumed by App plugin
  • Applications can decide what to do with notifications (show alert, display in list, etc.)

Test Cases

Test cases are available at: https://github.com/ikon-integration/Capacitor-Blob-Download-Issue

Changes from original PR #5498

  • Resolved all merge conflicts with current main branch
  • Maintained compatibility with existing code structure
  • Preserved all bug fixes and improvements from the original PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants