You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+68Lines changed: 68 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -303,6 +303,26 @@ ReactNativeBlobUtil
303
303
304
304
**These files won't be removed automatically, please refer to [Cache File Management](#user-content-cache-file-management)**
305
305
306
+
**Use File Transformer**
307
+
308
+
If you need to perform any processing on the bytes prior to it being written into storage (e.g. if you want it to be encrypted) then you can use `transform` option. NOTE: you will need to set a transformer on the libray (see [Setting a File Transformer](#Setting-A-File-Transformer))
309
+
310
+
```js
311
+
ReactNativeBlobUtil
312
+
.config({
313
+
// response data will be saved to this path if it has access right.
// the path should be dirs.DocumentDir + 'path-to-file.anything'
322
+
console.log('The file saved to ', res.path())
323
+
})
324
+
```
325
+
306
326
#### Upload example : Dropbox [files-upload](https://www.dropbox.com/developers/documentation/http/documentation#files-upload) API
307
327
308
328
`react-native-blob-util` will convert the base64 string in `body` to binary format using native API, this process is done in a separated thread so that it won't block your GUI.
Sometimes you may need the files to be transformed after reading from storage or before writing into storage (eg encryption/decyrption). In order to perform the transformations, use `readFileWithTransform` and `writeFileWithTransform`. NOTE: you must set a transformer on the file in order for the transformation to happen (see [Setting a File Transformer](#Setting-A-File-Transformer)).
931
+
906
932
## Web API Polyfills
907
933
908
934
After `0.8.0` we've made some [Web API polyfills](https://github.com/RonRadtke/react-native-blob-util/wiki/Web-API-Polyfills-(experimental)) that makes some browser-based library available in RN.
909
935
910
936
- Blob
911
937
- XMLHttpRequest (Use our implementation if you're going to use it with Blob)
912
938
939
+
940
+
## Setting A File Transformer
941
+
942
+
Setting a file transformer will allow you to specify how data should be transformed whenever the library is writing into storage or reading from storage. A use case for this is if you want the files handled by this library to be encrypted.
943
+
944
+
If you want to use a file transformer, you must implement an interface defined in:
0 commit comments