forked from joltup/rn-fetch-blob
-
Notifications
You must be signed in to change notification settings - Fork 135
/
android.js
58 lines (50 loc) · 1.99 KB
/
android.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
// 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 { Platform } from 'react-native';
import ReactNativeBlobUtil from './codegenSpecs/NativeBlobUtils';
/**
* Send an intent to open the file.
* @param {string} path Path of the file to be open.
* @param {string} mime MIME type string
* @param {string} chooserTitle for chooser, if not set the chooser won't be displayed (see https://developer.android.com/reference/android/content/Intent.html#createChooser(android.content.Intent,%20java.lang.CharSequence))
* @return {Promise}
*/
function actionViewIntent(path, mime, chooserTitle) {
if(typeof chooserTitle === 'undefined') chooserTitle = null;
if(Platform.OS === 'android')
return ReactNativeBlobUtil.actionViewIntent(path, mime, chooserTitle);
else
return Promise.reject('ReactNativeBlobUtil.android.actionViewIntent only supports Android.');
}
function getContentIntent(mime) {
if(Platform.OS === 'android')
return ReactNativeBlobUtil.getContentIntent(mime);
else
return Promise.reject('ReactNativeBlobUtil.android.getContentIntent only supports Android.');
}
function addCompleteDownload(config) {
if(Platform.OS === 'android')
return ReactNativeBlobUtil.addCompleteDownload(config);
else
return Promise.reject('ReactNativeBlobUtil.android.addCompleteDownload only supports Android.');
}
function getSDCardDir() {
if(Platform.OS === 'android')
return ReactNativeBlobUtil.getSDCardDir();
else
return Promise.reject('ReactNativeBlobUtil.android.getSDCardDir only supports Android.');
}
function getSDCardApplicationDir() {
if(Platform.OS === 'android')
return ReactNativeBlobUtil.getSDCardApplicationDir();
else
return Promise.reject('ReactNativeBlobUtil.android.getSDCardApplicationDir only supports Android.');
}
export default {
actionViewIntent,
getContentIntent,
addCompleteDownload,
getSDCardDir,
getSDCardApplicationDir,
};