Closed SidWML closed 10 months ago
Have you set up the cors on your AWS bucket?
https://repost.aws/knowledge-center/s3-configure-cors
[
{
"AllowedHeaders": [
"Authorization"
],
"AllowedMethods": [
"GET",
"HEAD"
],
"AllowedOrigins": [
"*" <-- Put your whitelist URL here
],
"ExposeHeaders": [
"Access-Control-Allow-Origin"
]
}
]
Also don't forget to put fileType
<DocViewer
documents={[
{
uri: url,
fileType: "pdf",
},
]}
</DocViewer>
<DocViewer documents={[{uri:'/dum.doc', fileType: "doc",}]} pluginRenderers={DocViewerRenderers} /> but local doc files are not getting show there is an error
@roy-andri Thanks but I have a question if I paste the urls in the browser Iam able to download the pdfs but in the app it got stuck in a infinte loop loader
Thanks but I have a question if I paste the urls in the browser Iam able to download the pdfs but in the app it got stuck in a infinte loop loader
For this one, have you put the fileType
? Can you share your network tab while requesting the document from AWS? Is it getting 200?
@roy-andri Here it is
I guess there is something wrong with your CORS configuration, I will facing the same issue if I remove the CORS configuration from my AWS bucket.
@roy-andri Thank you very much
Hi @roy-andri thanks for the solution above its working for pdf but its not working for doc and docx
How do you handle the rendering process? Can you share your code, maybe there is something wrong with your rendering.
https://support.mozilla.org/en-US/kb/xframe-neterror-page
It's working fine on my Firefox
Hi @roy-andri thanks for the reply i appreciate this is the code
const docs = [{uri:docURL ,fileType:'doc'}]
<DocViewer
className='w-[60%]'
prefetchMethod="GET"
documents={docs}
pluginRenderers={
DocViewerRenderers
}
/>
Are you facing this error on the local or after you deploy the website? can you make sure the file type is doc, not docx?
Here is how I call this library, with this code, I can preview 3 different file types (doc/x,pdf,txt)
<DocViewer
documents={[
{
uri: url,
fileType: extension,
},
]}
config={{
header: { disableHeader: true },
pdfVerticalScrollByDefault: true,
}}
prefetchMethod="GET"
/>
@roy-andri and this is what I am getting when I open it in mirrosoft edge
@roy-andri its in local what is this extension the file I have to display 3 types pdf,doc and docx
what is this extension the file I have to display 3 types pdf,doc and docx
It's depends on your file, if your file is docx
then the fileType
should docx
as well
@roy-andri this is what in the network headers
@roy-andri
Have you tried using incognito tab?
no @roy-andri its not working what is the version you are using
"@cyntler/react-doc-viewer": "^1.14.1"
@roy-andri Iam using the same package thanks for the help
It seems your file URL is empty @SidWML
I also facing same issue if I try set the file URL using empty string.
It should contain your file URL
@roy-andri thanks man I have wrote a condition where Iam storing the docURL I missed to check .Thank you once again Its working
https://static-sq-chat.s3.amazonaws.com/uploads/98820cea/D_Strange-Girl_Meets_Boy_Penguin_Readers-1-min.pdf?AWSAccessKeyId=adghakdehaoyKLKHSnKLhljKLDHklabdx&Signature=fsdfDsfsfsfsfsfD&Expires=1704870237 <DocViewer documents={[{uri:'/movies100.pdf'}]} pluginRenderers={DocViewerRenderers} prefetchMethod="GET" /> Iam not able to load from the above path but files from local are working fine