rn-fetch-blob: Can't open pdf after download
Configurations of my pdf
CONTENT-TYPE | application/octet-stream
My code
const downloadPdf = (uri: string, nome: string): void => {
setLoading(true)
const {config, fs} = RNFetchBlob
const PictureDir = fs.dirs.DownloadDir
const options = {
fileCache: true,
addAndroidDownloads: {
useDownloadManager: true,
notification: true,
title: nome,
path: `${PictureDir}/${nome}`,
},
appendExt: 'pdf',
}
config(options)
.fetch('GET', uri, {
// Accept: 'application/json',
// 'Content-Type': 'multipart/form-data,octet-stream',
'Content-Type': 'multipart/form-data',
})
.then((_) => {
Snackbar.show({
text: 'Download realizado com sucesso!',
backgroundColor: colors.silverTree,
})
})
.catch((_) => {
Snackbar.show({
text: 'Error ao realizar download!',
backgroundColor: colors.valencia,
})
})
.finally(() => setLoading(false))
}
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 19
Was able to fix it by adding android:requestLegacyExternalStorage=“true” to my manifest file. Based on this https://medium.com/@sriramaripirala/android-10-open-failed-eacces-permission-denied-da8b630a89df
Hi @adaerodriguez,
I’m doing exactly this in my app. It works well on iOS ! However, on Android, it goes to a black screen on
And come back to the app. If i touch my notification on my phone, it redirects me to the file, which has been successfully downloaded on my phone.
Would you know what causes this issue ?
RN: 0.63.2 RN-Fetch-Blob: 0.12.0
Same here, it opens the pdf app for a split second but comes back directly to my app. Pressing the notification or accessing through the file app works fine tho…
Só falta seu código pra abrir aquele file, né?
Same issue here, any update?
Here’s my code :
Before this I ask READ and WRITE permission on Android :
And I have the following in AndroidManifest :
Thanks,
A mi me srivio este codigo tanto en Ios y Android
The file is well downloaded. The thing i can’t do is open it with
RNFetchBlob.android.actionViewIntent