[ad_1]
I attempt a whole lot of issues however noting actually work.
I attempt to obtain a docx file in iOS, utilizing React-Native and RNFetchBlob.
To try this, I obtain the file from an URL (API). The obtain work fantastic however I am unable to get the ultimate doc.
That is my code :
const { config, fs } = RNFetchBlob
var token = await getToken();
const hyperlink = host + api
let path;
if (Platform.OS === 'ios')
path = fs.dirs.DocumentDir + "/docx/myFile" + second().format("DD-MM-YYYY") + ".docx"
if (Platform.OS === 'android')
path = fs.dirs.DownloadDir + "/docx/myFile" + second().format("DD-MM-YYYY") + ".docx"
return config({
fileCache: true,
useDownloadManager: true,
notification: true,
path: path,
mime : 'software/vnd.openxmlformats-officedocument.wordprocessingml.doc',
description: 'Downloading from App',
})
.fetch(requestType, hyperlink, {
Authorization: token,
'Content material-Sort': mimetype_attachment,
})
.then((res) => {
if (Platform.OS === 'android'){
ToastAndroid.present(I18n.t("downloadComplete"), ToastAndroid.LONG)
RNFetchBlob.android.actionViewIntent(path, "software/vnd.ms-excel")
RNFetchBlob.android.addCompleteDownload({
title: I18n.t('downloading'),
description: I18n.t("downloadComplete"),
mime: 'software/vnd.openxmlformats-officedocument.wordprocessingml.doc',
path: path,
showNotification: true,
})
}
else{
RNFetchBlob.ios.openDocument(res.information);
Alert.alert(I18n.t('downloading'), I18n.t('downloadComplete'));
}
}).catch((error)=>{
Alert.alert(I18n.t('downloading'), I18n.t('downloadFailed'));
})
The result’s only a information with the trail of my file. After I open my file within the iPhone, the Phrase app cannot open it.
Is somebody has the identical drawback and an answer ?
I exact : I exploit the precise strategy to obtain an xlsx file (Excel) and it work actually fantastic (I simply exchange the extension and the decision API).
[ad_2]
