Alcumus / react-doc-viewer

Apache License 2.0
243 stars 103 forks source link

Could you support content-type to determine URL validity? #63

Open ElixirMike opened 3 years ago

ElixirMike commented 3 years ago

I'm storing images in firebase. These end up with a format like this:

https://firebasestorage.googleapis.com/v0/b/graceblocks-4efeb.appspot.com/o/customers%2Fschema_1%2Fattachments%2F67282db5-5a8c-4d66-9862-968ce6fcecf3.jpg?alt=media&token=35f685d8-c449-42cc-bafe-cc70e44370e5

The DocViewer doesn't recognize this URL as a .JPG even though it is. Is there anyway to add support where we specify the content-type of the URL instead of relying on the extension itself?

jojonarte commented 3 years ago

I think you can implement a custom fileLoader for this

auronsan commented 3 years ago

got same issue. @jojonarte mind to share how fileloader work on .doc for office api? seems hard

ThatOneAwkwardGuy commented 3 years ago

Also would be interested in a solution to this

ThatOneAwkwardGuy commented 3 years ago

Nevermind, my solution was to add the config that maintains URL params when they're being loaded. <DocViewer documents={docs} config={{ header: { disableHeader: false, disableFileName: false, retainURLParams: true } }} />

The main error is coming from the doc viewer making a HEAD request to try and figure out what the doctype is, so you'll have to specify what the doctype is for each document you use:

documents={[{ uri: fileURL, fileType: extension (e.g "png or pdf .etc") }]}