I'm trying to use Flysystem v3 to write processed image files to a folder, and for those processed images to then be accessible via a standard Apache web server. In cases where the target folder is not available, I am getting Flysystem to create the folder too.
For the server I'm using, and for the files to be visible the permissions on the directory the processed images are written to needs to be set to 0775.
I have got most of this working, but try as I might I simply cannot get Flysystem to create the folder with the right permissions.
I'm creating the adapter with this construct:
$this->adapter = new \League\Flysystem\Local\LocalFilesystemAdapter(
// Determine the root directory
$syspathRoot,
// Customize how visibility is converted to unix permissions
\League\Flysystem\UnixVisibility\PortableVisibilityConverter::fromArray([
'file' => [
'public' => 0644,
'private' => 0600,
],
'dir' => [
'public' => 0775,
'private' => 0700,
],
], \League\Flysystem\Visibility::PUBLIC),
);
$filesystem = new \League\Flysystem\Filesystem($this->adapter);
which is based on what I found in a posting on the League Github.
When I create the directory I am using the following:
// Create directory if we can
try {
$filesystem->createDirectory($path, ['visibility' => 'public', 'directory_visibility' => 'public']);
} catch (\League\Flysystem\FilesystemException | \League\Flysystem\UnableToCreateDirectory $e) {
// handle the error
}
However whatever I try, these constructs cause directory to be created with 0755 permissions not 0775 permissions (and as a result the contents of the folder are not visible to web users).
I even tried changing the default values set in the PortableVisibilityConverter class (where oddly they appear to be set twice), but without beneficial improvement in results.
Hopefully I'm doing something unsensible - if so I would very much appreciate any guidance that can be offered. I have read the Flysytem docs exhaustively, poked around in Flysystem code and searched extensively for discussions of this issue, but so far not found much that is helpful. Fingers crossed someone reading this will be able to point me in the right direction.