title: How to send POST request with files in react-native android
body: <p>I'm trying to send a file with rect-native 62.2 code with fetch request
  when i select the file my fill array is this -> </p>
  
  <pre><code>{"data": ~blob image data~,"fileName": "Screenshot_20200504_082033.jpg", "fileSize": 347275, "height": 1544, "isVertical": true, "originalRotation": 0, "path": "/storage/emulated/0/DCIM/Screenshots/Screenshot_20200504_082033.jpg", "timestamp": "2020-05-04T02:50:33Z", "type": "image/jpeg", "uri": "content://media/external/images/media/126441", "width": 720}
  </code></pre>
  
  <p>i'm using the library for selecting the data is <code>react-native-image-picker</code> </p>
  
  <p>the fetch request i'm sending is will look like this</p>
  
  <pre><code>var picForm = new FormData();
            picForm.append('userId', userId);
            picForm.append('file', source) // &lt;- this is the main data
  fetch(API_HOST + 'user/profilePictureUpload', {
              method: 'POST',
              headers: {
                Accept: 'application/json',
                'Content-Type': 'multipart/form-data',
                Authorization: 'Basic jfjsfhsjkfhsjkjksksjjksfjkskfksdd',
                Authorizationkeyfortoken:''fjsfsfjsfsjhfsjkfhjksfjksfjsf,
              },
              body: picForm,
            }).then(res =&gt; res.text()).then(text =&gt; console.log(text)).catch(e =&gt; console.log(e));
  </code></pre>
  
  <p>for this code i'm getting an error <code>source</code> is <code>[TypeError: Network request failed]</code>
   when i try this</p>
  
  <pre><code>    var picForm = new FormData();
                picForm.append('userId', userId);
                picForm.append('file', {
    uri: source.uri, //&lt;- content://media/external/images/media/126441
    type: 'image/jpeg',
    name: source.fileName //&lt;- Screenshot_20200504_082033.jpg
  })
  </code></pre>
  
  <p>for this code i'm getting an error <code>source</code> is <code>[TypeError: Network request failed]</code></p>
  
  <pre><code>var picForm = new FormData();
            picForm.append('userId', userId);
            picForm.append('file', source.files[0]) // &lt;- this is the main data
  </code></pre>
  
  <p>the error  appear is undefined object</p>
  
  <pre><code> var picForm = new FormData();
                picForm.append('userId', userId);
                picForm.append('file', 'files') // &lt;- this is the main data
  </code></pre>
  
  <p>the network is correct but this is not i want to send this is the simple string do you guys any idea how to send the file with fetch request</p>