|
@@ -229,16 +229,26 @@ export default class Blob extends EventTarget {
|
229
|
229
|
if(this._closed)
|
230
|
230
|
throw 'Blob has been released.'
|
231
|
231
|
log.verbose('slice called', start, end, contentType)
|
|
232
|
+
|
|
233
|
+
|
232
|
234
|
let resPath = blobCacheDir + getBlobName()
|
233
|
235
|
let pass = false
|
234
|
236
|
log.debug('fs.slice new blob will at', resPath)
|
235
|
237
|
let result = new Blob(RNFetchBlob.wrap(resPath), { type : contentType }, true)
|
236
|
|
- fs.slice(this._ref, resPath, start, end).then((dest) => {
|
|
238
|
+ fs.exists(blobCacheDir)
|
|
239
|
+ .then((exist) => {
|
|
240
|
+ if(exist)
|
|
241
|
+ return Promise.resolve()
|
|
242
|
+ return fs.mkdir(blobCacheDir)
|
|
243
|
+ })
|
|
244
|
+ .then(() => fs.slice(this._ref, resPath, start, end))
|
|
245
|
+ .then((dest) => {
|
237
|
246
|
log.debug('fs.slice done', dest)
|
238
|
247
|
result._invokeOnCreateEvent()
|
239
|
248
|
pass = true
|
240
|
249
|
})
|
241
|
250
|
.catch((err) => {
|
|
251
|
+ console.warn('Blob.slice failed:', err)
|
242
|
252
|
pass = true
|
243
|
253
|
})
|
244
|
254
|
log.debug('slice returning new Blob')
|