| 
				
			 | 
			
			
				@@ -2,15 +2,15 @@ 
			 | 
		
	
		
			
			| 
				2
			 | 
			
				2
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				3
			 | 
			
				3
			 | 
			
			
				 ## v0.5.0 Work In Progress README.md 
			 | 
		
	
		
			
			| 
				4
			 | 
			
				4
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				5
			 | 
			
				
			 | 
			
			
				-Module for upload, download, and files access in JS context. Supports file stream read/write for process large files. 
			 | 
		
	
		
			
			| 
				
			 | 
			
				5
			 | 
			
			
				+A module provides upload, download, and files access API. Supports file stream read/write for process large files. 
			 | 
		
	
		
			
			| 
				6
			 | 
			
				6
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				7
			 | 
			
				7
			 | 
			
			
				 **Why do we need this** 
			 | 
		
	
		
			
			| 
				8
			 | 
			
				8
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				9
			 | 
			
				9
			 | 
			
			
				 At this moment, React Native does not support `Blob` object yet, so if you're going to send/receive binary data via `fetch` API, that might not work as you expect. See [[fetch] Does fetch with blob() marshal data across the bridge?](https://github.com/facebook/react-native/issues/854).  
			 | 
		
	
		
			
			| 
				10
			 | 
			
				10
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				11
			 | 
			
				
			 | 
			
			
				-Therefore you may getting into trouble sometime. For example, you're going to display an image but the file server requires a specific field(for example, "Authorization") in headers or body, you can't just pass the image uri to `Image` component because that will probably returns a 401 response. With help of this module, you can send a HTTP request with any headers, and decide how to handle the response data. It can be just simply converted into BASE64 string, or store to a file directly so that you can read it by file stream or use it's path.  
			 | 
		
	
		
			
			| 
				
			 | 
			
				11
			 | 
			
			
				+Hence you may getting into trouble in some use cases. For example, displaying an image on image server but the server requires a specific field(such as "Authorization") in headers or body, so you can't just pass the image uri to `Image` component because that will probably returns a 401 response. With help of this module, you can send a HTTP request with any headers, and decide how to handle the response/reqeust data. It can be just simply converted into BASE64 string, or store to a file directly so that you can read it by file stream or use it's path.  
			 | 
		
	
		
			
			| 
				12
			 | 
			
				12
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				13
			 | 
			
				
			 | 
			
			
				-This module is designed for these kind of purpose, and also be a substitution of `blob`, so there's a set of file access API added after `v0.5.0`, including basic CRUD method, and file stream reader and writer. 
			 | 
		
	
		
			
			| 
				
			 | 
			
				13
			 | 
			
			
				+This module is designed to be a substitution of `blob`, there's a set of file access API including basic CRUD method, and file stream reader/writer. Also it has a special `fetch` implementation that supports binary request/response body. 
			 | 
		
	
		
			
			| 
				14
			 | 
			
				14
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				15
			 | 
			
				15
			 | 
			
			
				 **Pre v0.5.0 Users** 
			 | 
		
	
		
			
			| 
				16
			 | 
			
				16
			 | 
			
			
				  
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -19,12 +19,12 @@ This update is `backward-compatible` generally you don't have to change existing 
			 | 
		
	
		
			
			| 
				19
			 | 
			
				19
			 | 
			
			
				 ## TOC 
			 | 
		
	
		
			
			| 
				20
			 | 
			
				20
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				21
			 | 
			
				21
			 | 
			
			
				 * [Installation](#user-content-installation) 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				
			 | 
			
			
				-* [Usages](#user-content-usage) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				22
			 | 
			
			
				+* [Guide](#user-content-guide) 
			 | 
		
	
		
			
			| 
				23
			 | 
			
				23
			 | 
			
			
				  * [Download file](#user-content-download-example--fetch-files-that-needs-authorization-token) 
			 | 
		
	
		
			
			| 
				24
			 | 
			
				24
			 | 
			
			
				  * [Upload file](#user-content-upload-example--dropbox-files-upload-api) 
			 | 
		
	
		
			
			| 
				25
			 | 
			
				25
			 | 
			
			
				  * [Multipart/form upload](#user-content-multipartform-data-example--post-form-data-with-file-and-data) 
			 | 
		
	
		
			
			| 
				26
			 | 
			
				26
			 | 
			
			
				  * [Upload/Download progress](#user-content-uploaaddownload-progress) 
			 | 
		
	
		
			
			| 
				27
			 | 
			
				
			 | 
			
			
				- * [Show Downloaded File and Notification in Android Downloads App](#user-content-show-downloaded-file-in-android-downloads-app) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				27
			 | 
			
			
				+ * [Android Media Scanner, and Downloads App Support](#user-content-android-media-scanner-and-downloads-app-support) 
			 | 
		
	
		
			
			| 
				28
			 | 
			
				28
			 | 
			
			
				  * [File access](#user-content-file-access) 
			 | 
		
	
		
			
			| 
				29
			 | 
			
				29
			 | 
			
			
				  * [File stream](#user-content-file-stream) 
			 | 
		
	
		
			
			| 
				30
			 | 
			
				30
			 | 
			
			
				  * [Manage cached files](#user-content-manage-cached-files) 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -69,7 +69,7 @@ If you're going to access external storage (say, SD card storage), you might hav 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				69
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				70
			 | 
			
				70
			 | 
			
			
				 ``` 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				71
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				72
			 | 
			
				
			 | 
			
			
				-## Usage 
			 | 
		
	
		
			
			| 
				
			 | 
			
				72
			 | 
			
			
				+## Guide 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				73
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				74
			 | 
			
				74
			 | 
			
			
				 ```js 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				75
			 | 
			
			
				 import RNFetchBlob from 'react-native-fetch-blob' 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -296,9 +296,29 @@ In `version >= 0.4.2` it is possible to know the upload/download progress. 
			 | 
		
	
		
			
			| 
				296
			 | 
			
				296
			 | 
			
			
				     }) 
			 | 
		
	
		
			
			| 
				297
			 | 
			
				297
			 | 
			
			
				 ``` 
			 | 
		
	
		
			
			| 
				298
			 | 
			
				298
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				299
			 | 
			
				
			 | 
			
			
				-#### Show Downloaded File and Notifiction in Android Downloads App 
			 | 
		
	
		
			
			| 
				
			 | 
			
				299
			 | 
			
			
				+#### Android Media Scanner, and Downloads App Support 
			 | 
		
	
		
			
			| 
				300
			 | 
			
				300
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				301
			 | 
			
				
			 | 
			
			
				-When you use `config` API to store response data to file, the file won't be visible in Andoird's "Download" app, if you want to do this, some extra options in `config` is required. 
			 | 
		
	
		
			
			| 
				
			 | 
			
				301
			 | 
			
			
				+If you want to make a file in `External Storage` becomes visible in Picture, Misuc, or other built-in apps, you will have to use `Media Scanner`. To make this happend, use `scanFile` method in `fs`. 
			 | 
		
	
		
			
			| 
				
			 | 
			
				302
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				303
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				304
			 | 
			
			
				+```js 
			 | 
		
	
		
			
			| 
				
			 | 
			
				305
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				306
			 | 
			
			
				+RNFetchBlog 
			 | 
		
	
		
			
			| 
				
			 | 
			
				307
			 | 
			
			
				+    .fetch('GET', 'http://example.com/music.mp3') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				308
			 | 
			
			
				+    .then((res) => RNFetchBlob.fs.scanFile([ { path : res.path(), mime : 'audio/mpeg' } ])) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				309
			 | 
			
			
				+    .then(() => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				310
			 | 
			
			
				+        // scan file success 
			 | 
		
	
		
			
			| 
				
			 | 
			
				311
			 | 
			
			
				+    }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				312
			 | 
			
			
				+    .catch((err) => { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				313
			 | 
			
			
				+        // scan file error 
			 | 
		
	
		
			
			| 
				
			 | 
			
				314
			 | 
			
			
				+    }) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				315
			 | 
			
			
				+``` 
			 | 
		
	
		
			
			| 
				
			 | 
			
				316
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				317
			 | 
			
			
				+If mime is null or undefined, then the mime type will be inferred from the file extension. 
			 | 
		
	
		
			
			| 
				
			 | 
			
				318
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				319
			 | 
			
			
				+**Download Notification and Visibiliy in Download App** 
			 | 
		
	
		
			
			| 
				
			 | 
			
				320
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				321
			 | 
			
			
				+Generally, when you store a file into  
			 | 
		
	
		
			
			| 
				302
			 | 
			
				322
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				303
			 | 
			
				323
			 | 
			
			
				 ```js 
			 | 
		
	
		
			
			| 
				304
			 | 
			
				324
			 | 
			
			
				 RNFetchBlob.config({ 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -320,6 +340,7 @@ RNFetchBlob.config({ 
			 | 
		
	
		
			
			| 
				320
			 | 
			
				340
			 | 
			
			
				 .then(...) 
			 | 
		
	
		
			
			| 
				321
			 | 
			
				341
			 | 
			
			
				 ``` 
			 | 
		
	
		
			
			| 
				322
			 | 
			
				342
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				
			 | 
			
				343
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				323
			 | 
			
				344
			 | 
			
			
				 #### File Access 
			 | 
		
	
		
			
			| 
				324
			 | 
			
				345
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				325
			 | 
			
				346
			 | 
			
			
				 File access APIs were made when developing `v0.5.0`, which helping us write tests, and was not planned to be a part of this module. However I realized that, it's hard to find a great solution to manage cached files, every one who use this moudle may need those APIs for there cases. 
			 |