Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const openPicker = async () => {
console.tron.debug(DocumentPicker.types)
try {
const res = await DocumentPicker.pick({
type: [DocumentPicker.types.allFiles],
})
console.log(
res.uri,
res.type, // mime type
res.name,
res.size
)
console.tron.debug('URI')
console.tron.debug(res)
const name = decodeURIComponent(res.uri)
if (name.startsWith(CONTENT_PREFIXES.RESILLIO_SYNC)) {
const realPath = name.replace(CONTENT_PREFIXES.RESILLIO_SYNC, '')
const openPicker = async () => {
console.tron.debug(DocumentPicker.types)
try {
const res = await DocumentPicker.pick({
type: [DocumentPicker.types.allFiles],
})
console.log(
res.uri,
res.type, // mime type
res.name,
res.size
)
console.tron.debug('URI')
console.tron.debug(res)
const name = decodeURIComponent(res.uri)
if (name.startsWith(CONTENT_PREFIXES.RESILLIO_SYNC)) {
const realPath = name.replace(CONTENT_PREFIXES.RESILLIO_SYNC, '')
const content = await RNFetchBlob.fs.readFile(realPath, 'utf8')
const stat = await RNFetchBlob.fs.stat(realPath, 'utf8')
console.tron.debug(stat)
onPress: async () => {
setActiveTab(TabItems.Files)
try {
const res = await DocumentPicker.pick({
type: [DocumentPicker.types.allFiles],
})
prepareMediaAndSend([
{
filename: res.name,
uri: res.uri,
mimeType: res.type,
},
])
} catch (err) {
if (DocumentPicker.isCancel(err)) {
// ignore
}
}
},
},
chooseFile = async() => {
try {
const res = await DocumentPicker.pick({
type: [DocumentPicker.types.allFiles]
});
this.showUploadModal({
filename: res.name,
size: res.size,
mime: res.type,
path: res.uri
});
} catch (e) {
if (!DocumentPicker.isCancel(e)) {
log(e);
}
}
}
onPress = async ()=>{
let files = []
try{
files = await DocumentPicker.pickMultiple({
type: [
DocumentPicker.types.images,
DocumentPicker.types.pdf,
DocumentPicker.types.plainText,
DocumentPicker.types.video,
...Platform.select({
ios: ['com.microsoft.word.doc', 'com.microsoft.excel.xls', 'com.microsoft.powerpoint.ppt', 'org.openxmlformats.wordprocessingml.document', 'org.openxmlformats.spreadsheetml.sheet', 'org.openxmlformats.presentationml.presentation', 'org.openxmlformats.presentationml.slideshow'],
android: ['application/*']//doc,etc...
})
],
})
}catch(e){}
if (!files.length)
return
Navigation.replace(this.props, 'bookmark/add/save', {
values: files.map(({name, uri, type})=>({
onPress = async ()=>{
let files = []
try{
files = await DocumentPicker.pickMultiple({
type: [
DocumentPicker.types.images,
DocumentPicker.types.pdf,
DocumentPicker.types.plainText,
DocumentPicker.types.video,
...Platform.select({
ios: ['com.microsoft.word.doc', 'com.microsoft.excel.xls', 'com.microsoft.powerpoint.ppt', 'org.openxmlformats.wordprocessingml.document', 'org.openxmlformats.spreadsheetml.sheet', 'org.openxmlformats.presentationml.presentation', 'org.openxmlformats.presentationml.slideshow'],
android: ['application/*']//doc,etc...
})
],
})
}catch(e){}
if (!files.length)
return
Navigation.replace(this.props, 'bookmark/add/save', {
values: files.map(({name, uri, type})=>({
uri,
private getBackupFile = async () => {
const res = await DocumentPicker.pick({
type: [DocumentPicker.types.plainText],
})
const importedData = await readFile(res.uri)
const encryptedBackup = this.validateImport(importedData)
if (encryptedBackup) {
this.props.recoverIdentity(encryptedBackup)
}
}
const {
profileImage,
profileImageRemove,
} = this.state;
const style = getStyleSheet(theme);
const uri = profileImage ? profileImage.uri : null;
return (