Created
July 8, 2019 02:59
-
-
Save hungtrn75/e8686ccacc4b628981d11f8b0d109cc4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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