Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 0896254

Browse files
committed
Add readBlob method to Blob for more easier content access
1 parent a73f437 commit 0896254

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/polyfill/Blob.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,23 @@ export default class Blob extends EventTarget {
196196
if(this._closed)
197197
throw 'Blob has been released.'
198198
log.verbose('slice called', start, end, encoding)
199+
console.warn('RNFB#Blob.slice() is not implemented yet, to read Blob content, use Blob.readBlob(encoding:string) instead.')
199200
// TODO : fs.slice
200201
// return fs.slice(this.cacheName, getBlobName(), contentType, start, end)
201202
}
202203

204+
/**
205+
* Read data of the Blob object, this is not standard method.
206+
* @nonstandard
207+
* @param {string} encoding Read data with encoding
208+
* @return {Promise}
209+
*/
210+
readBlob(encoding:string):Promise<any> {
211+
if(this._closed)
212+
throw 'Blob has been released.'
213+
return fs.readFile(this._ref, encoding || 'utf8')
214+
}
215+
203216
/**
204217
* Release the resource of the Blob object.
205218
* @nonstandard

0 commit comments

Comments
 (0)