- Newest
- Most votes
- Most comments
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
Hi,
-
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.
- 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.
- 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.
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.
Relevant content
- asked 9 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago