|
@@ -49,7 +49,7 @@ export default class Blob {
|
49
|
49
|
this.cacheName = getBlobName()
|
50
|
50
|
this.isRNFetchBlobPolyfill = true
|
51
|
51
|
this.type = mime
|
52
|
|
- log.verbose('Blob constructor called', 'mime', mime)
|
|
52
|
+ log.verbose('Blob constructor called', 'mime', mime, 'type', typeof data, 'length', data.length)
|
53
|
53
|
this._ref = blobCacheDir + this.cacheName
|
54
|
54
|
let p = null
|
55
|
55
|
// if the data is a string starts with `RNFetchBlob-file://`, append the
|
|
@@ -62,16 +62,16 @@ export default class Blob {
|
62
|
62
|
}
|
63
|
63
|
// content from variable need create file
|
64
|
64
|
else if(typeof data === 'string') {
|
65
|
|
- log.verbose('create Blob cache file from string')
|
66
|
65
|
let encoding = 'utf8'
|
67
|
|
- let mime = String(mime)
|
|
66
|
+ mime = String(mime)
|
68
|
67
|
// when content type contains application/octet* or *;base64, RNFetchBlob
|
69
|
68
|
// fs will treat it as BASE64 encoded string binary data
|
70
|
|
- if(mime.match(/application\/octet/i) || mime.match(/\;base64/i))
|
|
69
|
+ if(/(application\/octet|\;base64)/i.test(mime))
|
71
|
70
|
encoding = 'base64'
|
72
|
71
|
else
|
73
|
72
|
data = data.toString()
|
74
|
73
|
// create cache file
|
|
74
|
+ log.verbose('create Blob cache file from string', 'encode', encoding)
|
75
|
75
|
p = fs.writeFile(this._ref, data, encoding)
|
76
|
76
|
.then((size) => Promise.resolve(size))
|
77
|
77
|
|
|
@@ -184,6 +184,7 @@ function createMixedBlobData(ref, dataArray) {
|
184
|
184
|
return fs.appendFile.call(this, ...p)
|
185
|
185
|
})
|
186
|
186
|
return Promise.all(promises).then((sizes) => {
|
|
187
|
+ console.log('blob write size', sizes)
|
187
|
188
|
for(let i in sizes) {
|
188
|
189
|
size += sizes[i]
|
189
|
190
|
}
|