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)
}
}
}}
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)
}
}
}
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={
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')
attachFileFromFiles = async () => {
const {browseFileTypes} = this.props;
const hasPermission = await this.hasStoragePermission();
if (hasPermission) {
try {
const res = await DocumentPicker.pick({type: [browseFileTypes]});
if (Platform.OS === 'android') {
// For android we need to retrieve the realPath in case the file being imported is from the cloud
const newUri = await ShareExtension.getFilePath(res.uri);
if (newUri.filePath) {
res.uri = newUri.filePath;
} else {
return;
}
}
// Decode file uri to get the actual path
res.uri = decodeURIComponent(res.uri);
this.uploadFiles([res]);
} catch (error) {
// Do nothing
showDocumentPicker() {
const { t } = this.props;
DocumentPicker.pick({
type: isAndroid ? ['application/octet-stream'] : ['public.data', 'public.item', 'dyn.ah62d4rv4ge8003dcta'],
})
.then((res) => {
let path = res.uri;
if (path.startsWith('file://')) {
path = path.slice(7);
}
RNFetchBlob.fs
.readFile(path, 'ascii')
.then((data) => {
this.setState({ seedVault: data });
this.props.openPasswordValidationModal();
})
.catch(() =>
this.props.generateAlert(
'error',
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)
}
}
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);
}
}
}
chooseCertificate = async() => {
try {
const res = await DocumentPicker.pick({
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)) {