title: Get size Image and Video with RNFetchBlobStat
body: <p>I want when pick photo from device if size of photo > 10 MB or video >100 MB it will not pick. So I use RNFetchBlobStat to get size of photo and video.
  When I get detail info of photo from device it show size = 1.42MB but when RNFetchBlobStat  return size is 3466195 B. (ImagePicker fileSize have same result)
  Here is my code </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const MAX_SIZE_PHOTO = 10485760 //10*1024*1024
  const MAX_SIZE_VIDEO = 104857600//100*1024*1024
  getSizeImg = (type, source) =&gt; {
      RNFetchBlob.fs.stat(source.uri.replace('file:///', '').replace('file://', '').replace('file:/', ''))
          .then((stats) =&gt; {
              console.log("file size", stats.size)
              if (type === 'video') {
                  if (stats.size &gt; MAX_SIZE_VIDEO) {
                      Alert.alert(null, "This video is too large to be uploaded")
                      error()
                      return
                  }
                  uploadVideo(source, completeHandler, progressHandler, error, diary_id, token)
              } else {
                  if (stats.size &gt; MAX_SIZE_PHOTO) {
                      Alert.alert(null, "This image is too large to be uploaded")
                      error()
                      return
                  }
                  uploadImage(source)
              }
          })
          .catch((err) =&gt; {
              console.log("getSize", err)
              error(err)
          })
  }
  
  export let choiceImage = (openLibrary, completeHandler, progressHandler, error, closeLibrary, diary_id, token) =&gt; {
      console.log("choiceImage", diary_id, token)
      ImagePicker.showImagePicker(optionsImage, (response) =&gt; {
          if (response.didCancel) {
              closeLibrary();
          }
          else if (response.error) {
              error()
          }
          else if (response.customButton) {
              console.log('User tapped custom button: ', response.customButton);
          }
          else {
              // openLibrary(response.uri, 'image');
              let source = {
                  uri: response.uri,
                  name: response.fileName ? response.fileName : 'image.png',
                  type: 'image/*',
              };
              getSizeImg('image', source);
          }
      });
  }
  
  const isIOS = Platform.OS === 'ios';
  
  /**
   * FUNCTION CHOICE VIDEO FROM LIBRARY
   * @param func
   */
  export let choiceVideo = (openLibrary, completeHandler, progressHandler, error, closeLibrary, diary_id, token) =&gt; {
      ImagePicker.showImagePicker(optionsVideo, (response) =&gt; {
          console.log('Response = ', response);
          if (response.didCancel) {
              closeLibrary();
          }
          else if (response.error) {
              error();
          }
          else if (response.customButton) {
              console.log('User tapped custom button: ', response.customButton);
          }
          else {
              // openLibrary(isIOS ? response.uri : 'file://' + response.path, 'video');
              let source = {
                  uri: response.uri,
                  name: response.fileName ? response.fileName : "video.mp4",
                  type: 'video/*',
              };
              getSizeImg('video', source);
          }
      });
  }</code></pre>
  </div>
  </div>
  
  Why RNFetchBlobStat return size photo unlike size when get detail info photo from device?
  How I can fix it?</p>