【发布时间】:2016-06-10 01:30:35
【问题描述】:
我正在使用 Laravel 5.2 成功地将 .pdf 文件上传到我的 AWS S3 存储桶。我可以直接进入 AWS S3 上的存储桶并毫无问题地下载每个 .pdf。当我尝试使用以下代码下载某些 .pdf 文件时,浏览器或 Acrobat Pro 无法打开该文件。代码如下:
$file = Storage::disk('s3')->get($myfile);
// Set headers and force download
header("Content-type:application/pdf");
header("Content-Disposition:attachment;filename=file.pdf");
echo $file;
在浏览器中出现以下错误:Failed to load PDF document
在 Acrobat Pro 中,我收到以下错误:There was an error opening this document. The file is damaged and could not be repaired.
.pdf 可以在其他 Apple 程序中成功打开,例如 Preview 或 Skim。此外,可以成功上传和下载较旧的 .pdf 文件。
【问题讨论】:
标签: php pdf amazon-s3 laravel-5.2