|
@@ -238,6 +238,22 @@ class FetchBlobResponse {
|
238
|
238
|
return null
|
239
|
239
|
}
|
240
|
240
|
}
|
|
241
|
+ /**
|
|
242
|
+ * Read file content with given encoding, if the response does not contains
|
|
243
|
+ * a file path, show warning message
|
|
244
|
+ * @param {String} encoding Encode type, should be one of `base64`, `ascrii`, `utf8`.
|
|
245
|
+ * @return {String}
|
|
246
|
+ */
|
|
247
|
+ this.readFile = (encode: 'base64' | 'utf8' | 'ascii') => {
|
|
248
|
+ if(this.type === 'path') {
|
|
249
|
+ encode = encode || 'utf8'
|
|
250
|
+ return RNFetchBlob.fs.readFile(this.data, encode)
|
|
251
|
+ }
|
|
252
|
+ else {
|
|
253
|
+ console.warn('RNFetchblob', 'this response does not contains a readable file')
|
|
254
|
+ return null
|
|
255
|
+ }
|
|
256
|
+ }
|
241
|
257
|
}
|
242
|
258
|
|
243
|
259
|
}
|