Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onPress={async () => {
try {
const res = await DocumentPicker.pick({
// @ts-ignore
type: ['public.tar-archive', '*/*'],
})
await importAccount(res.uri.replace(/^file:\/\//, ''))
} catch (err) {
if (DocumentPicker.isCancel(err)) {
// ignore
} else {
console.error(err)
}
}
}}
avatar={
onPress={async () => {
try {
const res = await DocumentPicker.pick({
// @ts-ignore
type: ['public.tar-archive', '*/*'],
})
await importAccount(res.uri.replace(/^file:\/\//, ''))
} catch (err) {
if (DocumentPicker.isCancel(err)) {
// ignore
} else {
console.error(err)
}
}
}}
icon={'upload-outline'}
const onImportPress = async () => {
try {
const res = await DocumentPicker.pick({
// @ts-ignore
type: ['public.tar-archive', '*/*'],
})
await ctx.importAccount(res.uri.replace(/^file:\/\//, ''))
} catch (err) {
if (DocumentPicker.isCancel(err)) {
// ignore
} else {
console.error(err)
}
}
}
.catch((error) => {
// Do not show an alert if user cancels and does not pick a file
if (!DocumentPicker.isCancel(error)) {
return this.props.generateAlert(
'error',
t('global:somethingWentWrong'),
t('global:somethingWentWrongTryAgain'),
10000,
error,
);
}
});
}
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
}
}
},
},
type: ['com.rsa.pkcs-12']
});
const { uri: path, name } = res;
Alert.prompt(
I18n.t('Certificate_password'),
I18n.t('Whats_the_password_for_your_certificate'),
[
{
text: 'OK',
onPress: password => this.saveCertificate({ path, name, password })
}
],
'secure-text'
);
} catch (e) {
if (!DocumentPicker.isCancel(e)) {
log(e);
}
}
}
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);
}
}
}