FriendsOfCake / cakephp-upload

CakePHP: Handle file uploading sans ridiculous automagic
https://cakephp-upload.readthedocs.io/
MIT License
551 stars 255 forks source link

700 permission in subfolder using 'path' #589

Open pawel-sz opened 1 year ago

pawel-sz commented 1 year ago

It creates files, but created dir 'filename_dir' has only 700 permissions

`        $this->addBehavior('Josegonzalez/Upload.Upload', [
            'image' => [
                'keepFilesOnDelete' => false,
                'transformer' => function ($table, $entity, $data, $field, $settings, $filename) {
                    $this->patchEntity($entity, [
                        'filename' => $filename,
                    ]);
                    return [
                        $data->getStream()->getMetadata('uri') => $filename,
                    ];
                },
                'path' => 'webroot{DS}images{DS}{field-value:filename_dir}{DS}',
                'deleteCallback' => function (string $path, Image $entity) {
                    return [
                        $path . $entity->filename,
                    ];
                },
            ]
        ]);`

1

for example. this 6117de6f-dee3-4d1c-b38b-ceee9a8f8534 folder has 700 permission 2

pawel-sz commented 1 year ago

/vendor/josegonzalez/cakephp-upload/src/File/Writer/DefaultWriter.php linie 185, this change fix problem:

        if ($adapter instanceof FilesystemAdapter) {
            return new Filesystem($adapter, Hash::get($settings, 'filesystem.options', [
                'visibility' => Visibility::PUBLIC,
                'directory_visibility' => Visibility::PUBLIC,  //this line fix issue
            ]));
        }