question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ios.previewDocument is not working anymore

See original GitHub issue

Hi Everyone! Around two weeks ago previewDocument was broken for me without any packages updates. Before that, I was able to download PDFs and preview them also. Now only an empty file is coming.

Here is my code:

RNFetchBlob.config({
	fileCache: true,
	indicator: true,
	addAndroidDownloads: {
		useDownloadManager: true,
		notification: true,
		mime: 'application/pdf',
		title: `${fileName}`,
		path: `${dirs.DownloadDir}/${fileName}`,
		description: 'Diagnostic result',
	},
})
	.fetch('GET', `${BACKEND_URL}/${url}`, {
		Authorization: `Bearer ${authToken}`,
	})
	.then((res) => {
		const status = res.info().status;

		if (status === 200) {
			RNFetchBlob.fs.writeFile(filePath, res.data, 'base64');
			RNFetchBlob.ios.previewDocument(filePath);
		}
	})

I checked and file is being saved correctly in the temporary folder and it’s not empty there, but then when I read it with ios.previewDocument, the file is always empty. in popup which is appearing. After copying it’s also empty, in quick-look it’s also empty.

"rn-fetch-blob": "0.11.2" "react-native": "0.61.2"

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
lucasftcruzcommented, Sep 2, 2020

I figure out my problem, I was pointing to RNFetchBlob.fs.dirs.DownloadDir, but this is only available for Android. Changed to point to RNFetchBlob.fs.dirs.DocumentDir.

0reactions
SMJ93commented, May 30, 2022

Hey @qasimgit,

I would suggest finding a different library as this has been archived

Read more comments on GitHub >

github_iconTop Results From Across the Web

iOS 15 Simulator - Files App not s…
I observed that files in Documents folder of the iOS simulator(iOS 15.0) do not show up in the Files app anymore. Is there...
Read more >
react-native-file-viewer
Native file viewer for react-native. Preview any type of file supported by the mobile device. iOS: it uses QuickLook Framework. Android: it uses ......
Read more >
RN fetch blob download docx or pdf from URL in IOS
writeFile(configfb.path, res.data, 'base64'); RNFetchBlob.ios.previewDocument(configfb.path); } setisdownloaded(false) if (Platform.
Read more >
Paste image from the clipboard into a PDF in Preview
Doesn't work for me in Mojave. Which OS version have you tested this in? – benwiggy. Oct 27, 2020 at 17:04.
Read more >
8 Fixes for When Preview Fails to Open on Your Mac
app” is not open anymore. You can't open the application “Preview” because it is not responding. You may also see similar error messages...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found