showing results for - "upload files to server in react native"
Aislynn
10 Oct 2016
1//npm install react-native-fs --save
2
3/******************************************/
4import { uploadFiles, DocumentDirectoryPath } from "react-native-fs";
5
6var files = [
7  {
8    name: "file",
9    filename: "file.jpg",
10    filepath: DocumentDirectoryPath + "/file.jpg",
11    filetype: "image/jpeg",
12  },
13];
14
15uploadFiles({
16  toUrl: "https://upload-service-url",
17  files: files,
18  method: "POST",
19  headers: {
20    Accept: "application/json",
21  },
22  //invoked when the uploading starts.
23  begin: () => {},
24  // You can use this callback to show a progress indicator.
25  progress: ({ totalBytesSent, totalBytesExpectedToSend }) => {},
26});
27