How to upload files in React Native

A complete guide on how to handle multipart requests in React Native

Published in

JavaScript in Plain English

3 min read Mar 24, 2021

RNFetchBlob is a library whose purpose is to make our lives as React Native developers easier when dealing with transferring binary data.

In order to install it, run

npm install --save rn-fetch-blob
yarn add rn-fetch-blob

in your terminal.

Then go to your ios directory and run pod install .

In this article, we are going to look into uploading files. No worries, there’ll be a different one that will look into downloading files to the device.

The record object contains the basic info about the file that is to be uploaded:

export interface MedicalRecord description: string; 
file: File;
>
export interface PatientFile name: string;
url: string; // the path to the local file
size: number;
>