|
|
|
|
24
|
* [Upload file](#user-content-upload-example--dropbox-files-upload-api)
|
24
|
* [Upload file](#user-content-upload-example--dropbox-files-upload-api)
|
25
|
* [Multipart/form upload](#user-content-multipartform-data-example--post-form-data-with-file-and-data)
|
25
|
* [Multipart/form upload](#user-content-multipartform-data-example--post-form-data-with-file-and-data)
|
26
|
* [Upload/Download progress](#user-content-uploaaddownload-progress)
|
26
|
* [Upload/Download progress](#user-content-uploaaddownload-progress)
|
27
|
- * [Android Media Scanner, and Downloads App Support](#user-content-android-media-scanner-and-downloads-app-support)
|
|
|
|
|
27
|
+ * [Android Media Scanner, and Download Manager Support](#user-content-android-media-scanner-and-downloads-app-support)
|
28
|
* [File access](#user-content-file-access)
|
28
|
* [File access](#user-content-file-access)
|
29
|
* [File stream](#user-content-file-stream)
|
29
|
* [File stream](#user-content-file-stream)
|
30
|
* [Manage cached files](#user-content-manage-cached-files)
|
30
|
* [Manage cached files](#user-content-manage-cached-files)
|
|
|
|
|
303
|
})
|
303
|
})
|
304
|
```
|
304
|
```
|
305
|
|
305
|
|
306
|
-#### Android Media Scanner, and Downloads App Support
|
|
|
|
|
306
|
+#### Android Media Scanner, and Download Manager Support
|
307
|
|
307
|
|
308
|
-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`.
|
|
|
|
|
308
|
+If you want to make a file in `External Storage` becomes visible in Picture, Downloads, or other built-in apps, you will have to use `Media Scanner` or `Download Manager`.
|
309
|
|
309
|
|
|
|
310
|
+**Media Scanner**
|
|
|
311
|
+
|
|
|
312
|
+Media scanner scan the file and categorize by given MIME type, if MIME type not specified, it will try to resolve the file using its file extension.
|
310
|
|
313
|
|
311
|
```js
|
314
|
```js
|
312
|
|
315
|
|
313
|
-RNFetchBlog
|
|
|
|
|
316
|
+RNFetchBlob
|
314
|
.config({
|
317
|
.config({
|
315
|
// DCIMDir is in external storage
|
318
|
// DCIMDir is in external storage
|
316
|
path : dirs.DCIMDir + '/music.mp3'
|
319
|
path : dirs.DCIMDir + '/music.mp3'
|
|
|
|
|
325
|
})
|
328
|
})
|
326
|
```
|
329
|
```
|
327
|
|
330
|
|
328
|
-If mime is null or undefined, then the mime type will be inferred from the file extension.
|
|
|
|
|
331
|
+**Download Manager**
|
|
|
332
|
+
|
|
|
333
|
+When download large files on Android it is recommended to use `Download Manager`, it supports lot of native features like progress bar, and notification, also the download task will be handled by OS, and more effective.
|
|
|
334
|
+
|
|
|
335
|
+```js
|
|
|
336
|
+RNFetchBlob
|
|
|
337
|
+ .config({
|
|
|
338
|
+ // Optional, if not specified, the file will download to system default path
|
|
|
339
|
+ path : DOWNLOAD_DEST,
|
|
|
340
|
+ addAdnroidDownloads : {
|
|
|
341
|
+ useDownloadManager : true, // <-- this is the only thing required
|
|
|
342
|
+ // Optional, override notification setting (default to true)
|
|
|
343
|
+ notification : false,
|
|
|
344
|
+ // Optional, but recommended since android DownloadManager will fail when
|
|
|
345
|
+ // the url does not contains a file extension, by default the mime type will be text/plain
|
|
|
346
|
+ mime : 'text/plain',
|
|
|
347
|
+ description : 'File downloaded by download manager.'
|
|
|
348
|
+ }
|
|
|
349
|
+ })
|
|
|
350
|
+ .fetch('GET', 'http://example.com/file/somefile')
|
|
|
351
|
+```
|
|
|
352
|
+
|
329
|
|
353
|
|
330
|
**Download Notification and Visibiliy in Download App (Android Only)**
|
354
|
**Download Notification and Visibiliy in Download App (Android Only)**
|
331
|
|
355
|
|