ionic-team / ionic-team/capacitor
[Bug]: Android Capacitor Returns UTF-8 Binary String Instead of Blob for Binary Responses
- Dominant language
- TypeScript
- Stars
- 16.7k
- Forks
- 1.3k
- Avg merge
- 3d 15h
- Merged PRs (30d)
- 10
Description
### 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
```Shell
npm -v 10.9.2
node -v v23.9.0
```
### Platforms Affected
- [ ] iOS
- [x] 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

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

### 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.
Contributor guide
Assessment
This issue has not been assessed yet.