upload files to server in react native
//npm install react-native-fs --save
/******************************************/
import { uploadFiles, DocumentDirectoryPath } from "react-native-fs";
var files = [
{
name: "file",
filename: "file.jpg",
filepath: DocumentDirectoryPath + "/file.jpg",
filetype: "image/jpeg",
},
];
uploadFiles({
toUrl: "https://upload-service-url",
files: files,
method: "POST",
headers: {
Accept: "application/json",
},
//invoked when the uploading starts.
begin: () => {},
// You can use this callback to show a progress indicator.
progress: ({ totalBytesSent, totalBytesExpectedToSend }) => {},
});