From 75aa7a3756468f5e3679d7e564a427766f94b848 Mon Sep 17 00:00:00 2001 From: Eduardo K Date: Wed, 21 Jun 2017 02:27:29 +0300 Subject: [PATCH] Update troubleshooting with Permission denied --- docs/troubleshooting.md | 70 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index c3f86b3..39e2a75 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -20,4 +20,72 @@ public static function boot() static::bootStapler(); } -``` \ No newline at end of file +``` + +## mkdir(): Permission denied issue + +In case when files can be uploaded either from the web (with `www-data` user for example) and through the CLI (with `dev` user for example), you can face the issue, when `dev` user cannot write to the directory created with `www-data` user. + +Even though stapler is trying to create directory with `0777` permissions +``` + /** + * Determine if a style directory needs to be built and if so create it. + * + * @param string $filePath + */ + protected function buildDirectory($filePath) + { + $directory = dirname($filePath); + + if (!is_dir($directory)) { + mkdir($directory, 0777, true); + } + } + ``` + +php's umask can override that anyways. + +For this case you can override stapler's `Attachment` to disable `umask` temporary: + +``` +storageDriver, $method], $parameters); + + if ($method == 'move') { + umask($oldUmask); + } + + return $result; + } + } +} +```