forked from react-native-documents/document-picker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
37 lines (29 loc) · 1009 Bytes
/
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
'use strict';
import {Platform, NativeModules} from "react-native";
const DocumentPicker = NativeModules.RNDocumentPicker;
/**
* Android requires mime types, iOS is a bit more complicated:
*
* @see https://developer.apple.com/library/ios/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html
*/
class DocumentPickerUtil {
static allFiles() {
return (Platform.OS === 'android') ? "*/*" : "public.content";
}
static images() {
return (Platform.OS === 'android') ? "image/*" : "public.image";
}
static plainText() {
return (Platform.OS === 'android') ? "text/plain" : "public.plain-text";
}
static audio() {
return (Platform.OS === 'android') ? "audio/*" : "public.audio";
}
static video() {
return (Platform.OS === 'android') ? "video/*" : "public.video";
}
static pdf() {
return (Platform.OS === 'android') ? "application/pdf" : "com.adobe.pdf";
}
}
module.exports = {DocumentPickerUtil, DocumentPicker};