Closed MeTushar closed 5 years ago
Please post all relevant code and errors
This issue is not specific to this component. Have you tried to use jsonp or something similar? Another way to approach the problem might be to use iframes.
Hi,
I'm also trying to get an AWS file to display it.
Any news on this? I know I'm getting issues with CORS and trying to configure my bucket with this, but I'm still getting errors.
https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html
Thank you in advance.
Could you please share your code?
I found the solution, thanks.
I just sent from my api the PreSigned URL and it is working now
Then I assume the issue can be safely closed
I found the solution, thanks.
I just sent from my api the PreSigned URL and it is working now
Hi, I am using Pre Signed URL to display the S3 URL. First up i got "File Origin does not match" some how fixed that issue. After fixing that issue i am getting below error.
Error: Unexpected server response. Can you please guide me here.
@ani2479 For the benefit of others, would you be able to share the relevant code(which shows how to use a Presigned Url) ?
I'm not using this package, if you have specific errors, please share your code
As the OP found the answer, closing this issue
I want to follow up on this as I was uploading a generated PDF to Amazon s3 and then trying to use the s3 bucket URL to ng2-pdfjs but was hitting CORS errors in Chrome. The s3 bucket was a public bucket and there are CORS policies you can configure on the bucket itself. By default there are none, and that produces this wonderful error:
the has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
To fix this, you need to set a CORS policy on your bucket: Go to AWS Console > S3 > Your Bucket > Permissions > CORS Configuration and add something like this in the CORS configuration editor:
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
Click on Save and you should now be able to load the s3 bucket PDF in ng2-pdfjs.
https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html#how-do-i-enable-cors
I hope that helps someone in the future with using s3 and ng2-pdfjs.
What I ended up needing to do before even running into the CORS issue(s) was to encodeURIComponent(awsS3Url)
or I would just end up with an invalid URL due to how it is being passed into the iFrame. Thought I would throw that out to those that may not be getting a CORS error.
Not able to open pdf hosted in the foreign domain. Getting cors error. Is there any option to load pdf hosted in aws s3?