vinzscam/react-native-file-viewer

Cannot display pdf (file is of invalid format)

kosbog opened this issue · 3 comments

Have the Cannot display pdf (*file_name* is of invalid format) error on android. On iOS everything is fine. Also, I did an extra step for android api 30+.
Maybe its a wrong file path, i have this: /data/user/0/com.pmgmobileapp/cache/*file_name*.pdf.
Screenshot_20220204_160002

Versions:

"react-native-file-viewer": "^2.1.5",
"react-native": "0.66.4",

Android:

buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
ndkVersion = "21.4.7075529"

Code:

const options1: FetchInit = {
  method: 'GET',
  path: `${CACHED_PATH}/${file.name}`
};
const response = await FileSystem.fetch(`${CORE_URL}${url}`, options);
if (response) {
  const fileUri = `${Dirs.CacheDir}/${file.name}`;
  const fileStat = await FileSystem.stat(fileUri);
  await FileViewer.open(`${Dirs.CacheDir}/${file.name}`);
}

Already found a source of the problem and it is not related to this viewer.

Hello @kosbog how did you resolve this issue, as I also cannot open pdf links sent in Teams chat in Android?

@aidab98 hi. Sorry, I did not remember what exactly a problem I had. But it was not related to this viewer. I mean, something was wrong with the data that I had (wrong path or something like that, evil was hidden in details).