forked from RonRadtke/react-native-blob-util
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
74 lines (67 loc) · 2.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright 2016 wkh237@github. All rights reserved.
// Use of this source code is governed by a MIT-style license that can be
// found in the LICENSE file.
import {AppState, DeviceEventEmitter, NativeModules, Platform,} from 'react-native';
//import StatefulPromise from './class/StatefulPromise.js'
import fs from './fs';
import MediaCollection from './mediacollection';
import base64 from 'base-64';
import polyfill from './polyfill';
import android from './android';
import ios from './ios';
import JSONStream from './json-stream';
import {config, fetch} from './fetch';
import URIUtil from "./utils/uri";
const {
ReactNativeBlobUtilSession,
readStream,
createFile,
unlink,
exists,
mkdir,
session,
writeStream,
readFile,
ls,
isDir,
mv,
cp
} = fs;
const Blob = polyfill.Blob;
const emitter = DeviceEventEmitter;
const ReactNativeBlobUtil = NativeModules.ReactNativeBlobUtil;
const wrap = URIUtil.wrap;
// when app resumes, check if there's any expired network task and trigger
// their .expire event
if (Platform.OS === 'ios') {
AppState.addEventListener('change', (e) => {
if (e === 'active')
ReactNativeBlobUtil.emitExpiredEvent(() => {
});
});
}
// Show warning if native module not detected
if (!ReactNativeBlobUtil || !ReactNativeBlobUtil.fetchBlobForm || !ReactNativeBlobUtil.fetchBlob) {
console.warn(
'react-native-blob-util could not find valid native module.',
'please make sure you have linked native modules using `rnpm link`,',
'and restart RN packager or manually compile IOS/Android project.'
);
}
export {ReactNativeBlobUtilConfig, ReactNativeBlobUtilResponseInfo, ReactNativeBlobUtilStream} from './types';
export URIUtil from './utils/uri';
export {FetchBlobResponse} from './class/ReactNativeBlobUtilBlobResponse';
export getUUID from './utils/uuid';
export default {
fetch,
base64,
android,
ios,
config,
session,
fs,
wrap,
polyfill,
JSONStream,
MediaCollection
};