react-doc-viewer icon indicating copy to clipboard operation
react-doc-viewer copied to clipboard

react-doc-viewer stuck in loop making get requests to blob url or endpoint url for non-MS files

Open hrithvik123 opened this issue 2 years ago • 1 comments

When I try to load files that are not Microsoft documents, I tried grabbing the file and then generating a blob which is passed to react-doc-viewer as a uri. It seems to be throwing the library in a loop of get requests as shown in the screenshot below. Eventually the tab crashes.

Capture

Even if I try to just pass the secure endpoint URL to access the file, it behaves similarly and gets stuck making GET requests. If I pass an unsecure URL to publicly access the file, it works but the files are private and not meant to be publicly accessible.

Here's the function that grabs the file and returns a blob url ` export const LoadFile = async (url) => { const options = { method: 'GET', };

const response = await fetch(url, options);

if (response.status !== 200 && response.status !== 304) {
	return '';
}

const data = await response.blob();

const fileURL = URL.createObjectURL(data);

return fileURL;

}; `

This is then passed to the doc viewer as: [ { "uri": "blob:https://camfm.dev.streamdata.com/dbebf757-6efc-4d21-986f-98a2ca330155", "name": "file.pdf" } ]

Am I doing something wrong here or is it an issue with the library ?

hrithvik123 avatar Jun 29 '23 22:06 hrithvik123

same here, did you ever figure this out?

michaelbrant avatar Apr 01 '24 18:04 michaelbrant