|
@@ -146,19 +146,18 @@ RNFetchBlob
|
146
|
146
|
If you prefer a specific path rather than random generated one, you can use `path` option. We've added a [getSystemDirs](#user-content-getsysdirs) API in v0.5.0 that lists several common used directories.
|
147
|
147
|
|
148
|
148
|
```js
|
149
|
|
-RNFetchBlob.getSystemDirs().then((dirs) => {
|
150
|
|
- RNFetchBlob
|
151
|
|
- .config({
|
152
|
|
- // response data will be saved to this path if it has access right.
|
153
|
|
- path : dirs.DocumentDir + '/path-to-file.anything'
|
154
|
|
- })
|
155
|
|
- .fetch('GET', 'http://www.example.com/file/example.zip', {
|
156
|
|
- //some headers ..
|
157
|
|
- })
|
158
|
|
- .then((res) => {
|
159
|
|
- // the path should be dirs.DocumentDir + 'path-to-file.anything'
|
160
|
|
- console.log('The file saved to ', res.path())
|
161
|
|
- })
|
|
149
|
+let dirs = RNFetchBlob.fs.dirs
|
|
150
|
+RNFetchBlob
|
|
151
|
+.config({
|
|
152
|
+ // response data will be saved to this path if it has access right.
|
|
153
|
+ path : dirs.DocumentDir + '/path-to-file.anything'
|
|
154
|
+})
|
|
155
|
+.fetch('GET', 'http://www.example.com/file/example.zip', {
|
|
156
|
+ //some headers ..
|
|
157
|
+})
|
|
158
|
+.then((res) => {
|
|
159
|
+ // the path should be dirs.DocumentDir + 'path-to-file.anything'
|
|
160
|
+ console.log('The file saved to ', res.path())
|
162
|
161
|
})
|
163
|
162
|
```
|
164
|
163
|
|
|
@@ -537,24 +536,24 @@ RNFetchBlob.base64.decode(data)
|
537
|
536
|
|
538
|
537
|
`0.5.0`
|
539
|
538
|
|
540
|
|
-#### getSystemDirs():Promise
|
|
539
|
+#### getSystemDirs():Map<String, String>
|
541
|
540
|
|
542
|
541
|
This method returns common used folders:
|
543
|
542
|
- DocumentDir
|
544
|
543
|
- CacheDir
|
545
|
544
|
- DCIMDir (Android Only)
|
546
|
545
|
- DownloadDir (Android Only)
|
547
|
|
-- MisucDir (Android Only)
|
|
546
|
+- MusicDir (Android Only)
|
548
|
547
|
- PictureDir (Android Only)
|
549
|
548
|
- MovieDir (Android Only)
|
|
549
|
+- RingtoneDir (Android Only)
|
550
|
550
|
|
551
|
551
|
```js
|
552
|
|
-RNFetchBlob.getSystemDirs().then((dirs) => {
|
553
|
|
- console.log(dirs.DocumentDir)
|
554
|
|
- console.log(dirs.CacheDir)
|
555
|
|
- console.log(dirs.DCIMDir)
|
556
|
|
- console.log(dirs.DownloadDir)
|
557
|
|
-})
|
|
552
|
+const dirs = RNFetchBlob.fs.dirs
|
|
553
|
+console.log(dirs.DocumentDir)
|
|
554
|
+console.log(dirs.CacheDir)
|
|
555
|
+console.log(dirs.DCIMDir)
|
|
556
|
+console.log(dirs.DownloadDir)
|
558
|
557
|
```
|
559
|
558
|
> If you're going to make downloaded file visible in Android `Downloads` app, please see [Show Downloaded File and Notification in Android Downloads App](#user-content-show-downloaded-file-and-notifiction-in-android-downloads-app).
|
560
|
559
|
|