用于pdf的s3签名网址表示如果从浏览器访问但是与file_get_contents一起使用,则图像包含错误

I have generated a signed url for a pdf uploaded to s3. If I put this url directly in the browser or use the following sort of code it says "The image [signed url] cannot be displayed because it contains errors."

ob_clean();
header('Location: '.$url);

However, If I do something like this it works fine.

ob_clean();
header('Content-type: application/pdf');
echo file_get_contents($url);

Both versions work correctly for regular images. This issue is only for pdf files.