react-native-doc-viewer
react-native-doc-viewer copied to clipboard
Android: fileName has no effect
Env: "react": "16.4.0", "react-native": "0.53.3", "react-native-doc-viewer": "2.7.8"
The iOS part with file fileNameOptional works, but not the Android part on my Nexus 5X.
import RNFetchBlob from "react-native-fetch-blob";
import { Platform } from "react-native";
import OpenFile from "react-native-doc-viewer";
const OpenFileManager = OpenFile.openDoc;
const isIOS = Platform.OS === 'ios';
const fetchBlobOptions = { fileCache: true, appendExt: "pdf" };
export function PdfView(link: string, fileName: string) {
return new Promise((resolve, reject) => {
RNFetchBlob.config(fetchBlobOptions)
.fetch("GET", link, {})
.then(data => {
const options = createFileManagerOptions(data, fileName);
OpenFileManager(options,
(error, url) => {
if (error) {
reject(false);
} else {
resolve(true);
}
}
);
});
});
}
function createFileManagerOptions(data: Object, fileName: string) {
const options = [];
if (isIOS) {
options.push({
fileNameOptional: fileName,
url: data.path(),
});
} else {
options.push({
cache: false /*Use Cache Folder Android*/,
fileName: fileName,
fileType: "",
url: "file:/" + data.path(),
});
}
return options;
}
The name is always "RNFetchBlobTmp_q.........pdf"
Any ideas how to solve this? I checked the native part and in my eyes it looks good.