Skip to content

[Bug]: Android Capacitor Returns UTF-8 Binary String Instead of Blob for Binary Responses #7944

Open
@layola13

Description

@layola13

Capacitor Version

Capacitor Doctor

Latest Dependencies:

@capacitor/cli: 7.1.0
@capacitor/core: 7.1.0
@capacitor/android:
7.1.0
@capacitor/ios: 7.1.0

Installed Dependencies:

@capacitor/ios: not installed
@capacitor/cli: 7.1.0
@capacitor/core: 7.1.0
@capacitor/android: 7.1.0

[success] Android looking great! 👌

Other API Details

npm -v 10.9.2

 node -v v23.9.0

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

When making network requests with responseType: 'blob' on Android with Capacitor, instead of receiving a proper Blob object like on web platforms, the response is a UTF-8 encoded binary string. This inconsistency causes issues when trying to handle binary data like audio files across different platforms.

  • On web: response.data is a proper Blob object

Image

  • On Android: response.data is a UTF-8 encoded binary string

Image

Expected Behavior

When making a request with responseType: 'blob', the response should be a standard Blob object on all platforms (web and Android), allowing consistent code handling.

Project Reproduction

https://gist.github.com/layola13/55bd89421c9e82d066d584b80f0da551

Additional Information

This inconsistency makes it difficult to handle binary responses in a cross-platform manner. Ideally, Capacitor should normalize the response type to be consistent with web behavior, returning a proper Blob object when responseType: 'blob' is specified.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions