Im working on react native fetch blob to download the file. The file basically are in my nodejs server.
I have tried to get it from post man and its successfully working. But when i attached the api into rn-fetch-blob it shows me download failed even file exists. I have checked 10 time my installation is correct there is no issue there. Can any body help me to get out of this.
ТАК это мой узел api router.post ('/ download-proof', documents.proofDownload);
proofDownload: (req, res) => {let filepath = path.join (__dirname, '.. / .. / .. / documents /') + req.body.filename res.setHeader ('Content-Disposition', 'attachment; filename =' + req.body.filename); res.setHeader ('Content-Transfer-Encoding', 'двоичный'); res.setHeader ('Content-Type', req.body.mimetype); res.download (filepath)
},
отлично работает в почтальоне
Это rn-fetch-blob
let options = {
fileCache: true,
appendExt: getExt,
addAndroidDownloads: {
useDownloadManager: true, // setting it to true will use the device's native download manager and will be shown in the notification bar.
notification: true,
description: 'Downloading file.',
path:
pathToDir +
`/${file.filename}` ,
},
path:
pathToDir +
`/${file.filename}` ,
notification: true,
};
console.log(file," docs")
console.log(options.path, pathToDir,"options")
let body = {
filename: file.filename,
mimetype: file.mimetype
}
console.log(body, "line no 62")
let url = `http://3.21.33.146:3000/download-proof`;
console.log(url);
config(options)
.fetch("POST", url,{}, JSON.stringify(body))
.progress({interval: 250}, (received, total) => {})
.then((res) => {
console.log(res, "fetch blob response")
}).catch((err) => {
console.log(err)
})
} else {
Alert.alert(
"Permission Denied!",
"You need to give storage permission to download the file"
);
}
} catch (err) {
console.log(err);
}
}
Это дает мне ошибку кода состояния 16 не знаю, в чем проблема.