|
@@ -53,6 +53,7 @@ export default class XMLHttpRequest extends XMLHttpRequestEventTarget{
|
53
|
53
|
_headers: any = {
|
54
|
54
|
'Content-Type' : 'text/plain'
|
55
|
55
|
};
|
|
56
|
+ _cleanUp : () => void = null;
|
56
|
57
|
_body: any;
|
57
|
58
|
|
58
|
59
|
// RNFetchBlob promise object, which has `progress`, `uploadProgress`, and
|
|
@@ -158,9 +159,16 @@ export default class XMLHttpRequest extends XMLHttpRequestEventTarget{
|
158
|
159
|
log.debug('sending blob body', body._blobCreated)
|
159
|
160
|
promise = new Promise((resolve, reject) => {
|
160
|
161
|
body.onCreated((blob) => {
|
161
|
|
- log.debug('body created send request')
|
162
|
|
- body = RNFetchBlob.wrap(blob.getRNFetchBlobRef())
|
163
|
|
- resolve()
|
|
162
|
+ // when the blob is derived (not created by RN developer), the blob
|
|
163
|
+ // will be released after XMLHttpRequest sent
|
|
164
|
+ if(blob.isDerived) {
|
|
165
|
+ this._cleanUp = () => {
|
|
166
|
+ blob.close()
|
|
167
|
+ }
|
|
168
|
+ }
|
|
169
|
+ log.debug('body created send request')
|
|
170
|
+ body = RNFetchBlob.wrap(blob.getRNFetchBlobRef())
|
|
171
|
+ resolve()
|
164
|
172
|
})
|
165
|
173
|
})
|
166
|
174
|
}
|