laravel-pdf
laravel-pdf copied to clipboard
[Bug]: PDF files uploaded to S3 using the disk() method are corrupted
What happened?
I used the ->disk() method to upload to S3, but when I do this I can see that the file has double the expected size, and does not parse as a valid PDF.
How to reproduce the bug
This process, where I generate a PDF file locally and then manually copy to S3, works:
Pdf::view('messages.da.invite', $params)
->save($localFilePath);
$contents = file_get_contents($localFilePath);
$disk->put($filePath, $contents);
This version fails.
Pdf::view('messages.da.invite', $params)
->disk($diskName)
->save($filePath);
The file is created, but I can see that it is twice the expected size on S3 and that on copying back from S3, it fails to parse.
$filePath is the path on S3 from the bucket root. $diskName is the string key from config('filesystems.disks') - I expected actually to be able to pass an actual disk instance ($disk), but this did not work.
Hope I am not missing something obvious here!
Package Version
1.5.2
PHP Version
8.2.12
Laravel Version
10.48.20
Which operating systems does with happen with?
Ubuntu 20.04
Notes
Also installed:
league/flysystem-aws-s3-v3 3.28.0