Skip to content

Instantly share code, notes, and snippets.

@hungtrn75
Created July 8, 2019 02:59
Show Gist options
  • Save hungtrn75/e8686ccacc4b628981d11f8b0d109cc4 to your computer and use it in GitHub Desktop.
Save hungtrn75/e8686ccacc4b628981d11f8b0d109cc4 to your computer and use it in GitHub Desktop.
handleDownloadAttachment = (file) => {
Alert.alert(
'Tải tệp đính kèm', `Tải tệp: ${file.filename}?`,
[{
text: 'Hủy',
onPress: () => {}
},
{
text: 'Tải',
onPress: () => RNFetchBlob
.config({
addAndroidDownloads: {
useDownloadManager: true,
notification: true,
description: `Đã tải xuống ${file.filename}`
}
})
.fetch('GET', file.url, {})
.then((res) => {
// the temp file path
RNFetchBlob.fs.scanFile([{
path: res.path()
}])
})
.then(() => {
// scan file success
})
.catch((err) => {
// scan file error
})
},
], {
cancelable: true
},
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment