|
@@ -599,16 +599,36 @@ class RNFetchBlobFS {
|
599
|
599
|
callback.invoke("Source file at path `" + path + "` does not exist");
|
600
|
600
|
return;
|
601
|
601
|
}
|
|
602
|
+
|
|
603
|
+ //Check if the output file directory exists.
|
|
604
|
+ File dir = new File(dest);
|
|
605
|
+ if (!dir.exists())
|
|
606
|
+ {
|
|
607
|
+ dir.mkdirs();
|
|
608
|
+ }
|
|
609
|
+
|
602
|
610
|
try {
|
603
|
|
- boolean result = src.renameTo(new File(dest));
|
604
|
|
- if (!result) {
|
605
|
|
- callback.invoke("mv failed for unknown reasons");
|
606
|
|
- return;
|
|
611
|
+ InputStream in = new FileInputStream(path);
|
|
612
|
+ OutputStream out = new FileOutputStream(dest);
|
|
613
|
+
|
|
614
|
+ //read source path to byte buffer. Write from input to output stream
|
|
615
|
+ byte[] buffer = new byte[1024];
|
|
616
|
+ int read;
|
|
617
|
+ while ((read = in.read(buffer)) != -1) { //read is successful
|
|
618
|
+ out.write(buffer, 0, read);
|
607
|
619
|
}
|
|
620
|
+ in.close();
|
|
621
|
+ out.flush();
|
|
622
|
+
|
|
623
|
+ src.delete(); //remove original file
|
|
624
|
+ } catch (FileNotFoundException exception) {
|
|
625
|
+ callback.invoke(exception.toString());
|
|
626
|
+ return;
|
608
|
627
|
} catch (Exception e) {
|
609
|
|
- callback.invoke(e.getLocalizedMessage());
|
|
628
|
+ callback.invoke(e.toString());
|
610
|
629
|
return;
|
611
|
630
|
}
|
|
631
|
+
|
612
|
632
|
callback.invoke();
|
613
|
633
|
}
|
614
|
634
|
|