Some PDFs uploaded to S3 are given the Content-Type 'Image', and then won't open in a browser

0

I am using a Wordpress plugin called Media Cloud, which allows me to upload files into my CMS, which pass through to an S3 bucket. I'm not sure whether this is happening at the plugin level or the S3 level, but sometimes, when the PDF arrives in my bucket, the metadata shows the Content-Type as image/png, and not application/pdf.

This means that the PDF won't open in a browser, because the browser is trying to treat it as an image. Does anyone know why this might happen, and if there is a rule I can set to force all pdfs to have the PDF metadata?

질문됨 2년 전1793회 조회
1개 답변
0

The content-type metadata is set while uploading the file. Have you checked how your CMS processes and identifies files? It sounds like the error happens while the CMS is uploading it into S3. The default behaviour when uploading to S3 depends on the AWS SDK that your CMS uses.

If you can't fix this on the CMS side you could consider creating your own little Lambda function that is triggered when file is uploaded and it then checks if the content-type in metadata matches the file extension. If it doesn't it could update it automatically. Check out how to trigger Lambda based on S3 in our documentation.

profile pictureAWS
전문가
Toni_S
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠