Answers for "upload files to server in react native"

0

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 }) => {},
});
Posted by: Guest on September-28-2021

Code answers related to "upload files to server in react native"

Code answers related to "Javascript"

Browse Popular Code Answers by Language