Reputation: 51
I am using Docker running Laravel 5.1 to generate PDFs so my problem is the file gets generated successfully without errors and is saved to the mounted volume. The problem arises when i try to pull the file back to display it using Storage::disk('local')->get($filename);
I get
ErrorException in Local.php line 187:
file_put_contents(/app/storage/app/savedfile.pdf): failed to open stream: Permission denied.
I also tried changing the permissions from inside the docker container, and also manually on the mounted volume, it did not help.
Here is the code i used to save the file
$snappy = new Pdf('wkhtmltopdf');
$tmpFile = storage_path().'/app/savedfile.pdf';
$snappy->setOption('images', true);
$snappy->setOption('footer-right', '[page] OF [topage]');
$result = $snappy->generateFromHtml(
$view->render(),
$tmpFile
);
Storage::disk('local')->put('report.pdf', \File::get($tmpFile));
Does anyone know how i can resolve this?
Upvotes: 3
Views: 1357
Reputation: 51
Took me a while to try and fix this, but when docker for mac was anounced i quickly moved to it, i havent had permission issues since.
So i recommend you checkout Docker For Mac
Upvotes: 0
Reputation: 5223
Docker users are not the same as the host machine's. You need to make sure that the host machine's user and container's user that access the mounted volume have both access to the volume's files.
You can achieve this in a couple ways, for example:
After you make the change you should be able to read/write the pdf files.
Upvotes: 1