The pdf getting stored in S3 is not opening and giving an error on browsers

0

Error Failed to load PDF document.

This error appears when I try to open the PDF which is stored in S3 Bucket configured along with the Cloudfront via browser. I can view the PDF on browsers by clicking on the "Open" button in the S3 console, but if I open via CloudFront URL, it gives the "Error Failed to load PDF document".

3 Risposte
0

It seems may be content type issue. CloudFront servers may not determine the MIME type for the objects that they serve. When you upload a file to your origin, we recommend that you set the Content-Type header field for it.

reference : https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/AddingObjects.html

profile pictureAWS
ESPERTO
con risposta 3 mesi fa
profile picture
ESPERTO
verificato 2 mesi fa
0

Hi,

  1. Verify Permissions: Ensure that the permissions on the S3 bucket are configured correctly to allow access via CloudFront. Check both the bucket policy and any associated IAM roles or policies to make sure they are configured properly.

    2)Cache Invalidation: If you recently updated the PDF file or its permissions, it's possible that CloudFront is serving a cached version of the file that doesn't have the correct permissions. Try invalidating the CloudFront cache for the specific file or the entire distribution to force CloudFront to fetch a fresh copy from S3.

    3)Origin Configuration: Double-check the CloudFront distribution's origin configuration to ensure that it is correctly pointing to the S3 bucket and that the origin settings (such as protocol policy and origin access identity) are configured appropriately.

4 )Viewer Configuration: Ensure that the PDF viewer being used in the browser is compatible with the way the PDF file is being served via CloudFront. Some viewers may have restrictions or limitations when accessing files from certain sources.

  1. URL Encoding: Verify that the URL for accessing the PDF file via CloudFront is correctly encoded and formatted. Any issues with the URL structure could prevent the file from being loaded properly.
6)Error Logs:
Check the CloudFront access logs and S3 access logs for any errors or indications of what might be causing the problem. This can provide valuable insights into the specific issue.

7) SSL/TLS Configuration: Ensure that your SSL/TLS certificate is configured correctly for your CloudFront distribution, especially if you're using HTTPS. Misconfigurations in SSL/TLS settings can sometimes cause issues with loading certain types of content.

  1. Content-Type Headers: Ensure that the Content-Type headers for the PDF file in S3 are set correctly. CloudFront may rely on these headers to determine how to handle the file.
9)Cross-Origin Resource Sharing (CORS):
If you are accessing the PDF file from a different domain via CloudFront, ensure that CORS is properly configured on the S3 bucket to allow cross-origin requests.
profile picture
con risposta 3 mesi fa
0

Hi, thank you for your prompt response, After checking again, the response from Cloudfront can return the correct content type: application/pdf. I have observed that only pdf which is uploaded via AWS SDK V2 Java S3AsyncClient and S3TransferManager prompt this error.

con risposta 3 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande