Skip to content

fix(http): correctly serialize Blob objects in request bodies and FormData#8403

Open
vamsi2246 wants to merge 1 commit intoionic-team:mainfrom
vamsi2246:fix-blob-serialization
Open

fix(http): correctly serialize Blob objects in request bodies and FormData#8403
vamsi2246 wants to merge 1 commit intoionic-team:mainfrom
vamsi2246:fix-blob-serialization

Conversation

@vamsi2246
Copy link

Bug Report / Context

When using CapacitorHttp to intercept requests, dynamically generated Blob objects appended to FormData or passed as the request body are silently corrupted. Because the native bridge only checks if (value instanceof File), generic Blobs fall through the type check and are improperly serialized as the literal string "[object Blob]".

What This PR Does

Changes the strict File instance checks to Blob in native-bridge.ts. Since all File objects are instances of Blob, and FileReader.readAsBinaryString() natively accepts a Blob, this safely fixes the data corruption for both pure Blobs and Files without introducing any breaking changes.

  • Replaced instanceof File with instanceof Blob in convertFormData and convertBody.
  • Updated readFileAsBase64 signature to accept Blob.
  • Added a fallback fileName for generic Blobs that do not inherently have a .name property.

@jcesarmobile
Copy link
Member

can you first create an issue with a sample app that reproduces this problem?

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