Skip to content

feat: support react native blob objects#5764

Merged
jasonsaayman merged 15 commits intoaxios:v1.xfrom
moh3n9595:feat/support-react-native-blob-objects
Feb 24, 2026
Merged

feat: support react native blob objects#5764
jasonsaayman merged 15 commits intoaxios:v1.xfrom
moh3n9595:feat/support-react-native-blob-objects

Conversation

@moh3n9595
Copy link
Contributor

Add support for React Native "blob"s (objects with an uri field, React Native FormData implementation can be able to detect and upload them directly from filesystem).

@jasonsaayman jasonsaayman self-requested a review January 4, 2025 11:41
@jasonsaayman jasonsaayman added this to the v1.8.0 milestone Jan 4, 2025
@jasonsaayman jasonsaayman modified the milestones: v1.8.0, v1.9.0 Feb 21, 2025
@jasonsaayman jasonsaayman removed this from v1.9.0 Apr 25, 2025
@jasonsaayman jasonsaayman removed this from the v1.9.0 milestone Apr 25, 2025
@jasonsaayman jasonsaayman requested a review from Copilot November 11, 2025 18:24
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds support for React Native blob objects to enable proper handling of file uploads in React Native environments. React Native uses a special "blob" object structure with a uri field that differs from standard web Blob objects.

Key changes:

  • Added two new utility functions isReactNativeBlob and isReactNative for detecting React Native blob objects and environment
  • Modified toFormData helper to handle React Native blobs by checking for React Native FormData and blob objects before processing

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
lib/utils.js Added isReactNativeBlob and isReactNative utility functions to detect React Native blob objects and environment, exported them in the utils module
lib/helpers/toFormData.js Added conditional logic to append React Native blob objects directly when in a React Native environment

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.

@jasonsaayman
Copy link
Member

closing as this is stale, please re-open if you would like to have me review

@moh3n9595
Copy link
Contributor Author

Do you think we should change sth? @jasonsaayman

@jasonsaayman
Copy link
Member

sorry @moh3n9595 i may have closed this too hastily, could you please add unit tests for the changes then i think we can look to merge

@jasonsaayman jasonsaayman reopened this Jan 22, 2026
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 3 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="lib/utils.js">

<violation number="1" location="lib/utils.js:201">
P2: Guard against null/undefined before accessing `getParts`; the current implementation throws when `formData` is missing.</violation>
</file>

<file name="lib/helpers/toFormData.js">

<violation number="1" location="lib/helpers/toFormData.js:172">
P1: React Native blob check is inside the `!path` condition, so it only works for root-level properties. Nested blobs (e.g., `{ nested: { file: { uri: '...' } } }`) will be recursed into instead of being appended directly, since `isVisitable` returns true for plain objects. Consider moving this check outside the `if (value && !path && typeof value === 'object')` block, or adding a similar check before the `isVisitable` check.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@moh3n9595
Copy link
Contributor Author

I’ve added unit tests to cover the new React Native blob support.
@jasonsaayman, let me know if you’d like any changes or additional coverage before merging.

@jasonsaayman jasonsaayman added the commit::feat The PR is related to a feature label Feb 23, 2026
@jasonsaayman jasonsaayman merged commit 885b4af into axios:v1.x Feb 24, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commit::feat The PR is related to a feature priority::medium A medium priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants