How to import excel file in react-native to upload in api

49 Views Asked by At

I want to pick excel file from my phone storage and upload in api

I try to pick excel file from react-native-document-picker

but in the response I got URI in this format content://com.android.providers.downloads.documents/document/8633

with this I'm not able to upload excel file in api

1

There are 1 best solutions below

0
Khushal Agarwal On

Did you try replacing content// with file// and uploading? Also, make sure you upload form data by appending file uri, name and type.

To replace you can use:

// Convert URI to file path
    const filePath = res.uri.replace('content://', 'file://');

If it doesn't work please share your code snippet. Thanks :)