Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve) => {
DocumentPicker.show({ filetype: [DocumentPickerUtil.allFiles()] }, (error, res) => {
if (error) {
// Also returns an error if the user doesn't pick a file
// so just resolve with null.
console.info('pickDocument error:', error);
resolve(null);
return;
}
resolve(res);
});
});
}
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')
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 () => {
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)
}
}
}