N
N
netrox2018-11-07 11:20:02
Laravel
netrox, 2018-11-07 11:20:02

How to specify permissons when creating a directory?

Create a directory on the remote server and place the . I connect via sftp and Storage::disk('sftp')->makeDirectory('path')create a folder with the help, but I can’t put the file there (imposes 0744). Is there any way to specify permissions when creating ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel Tereshchenko, 2018-12-24
@l2ping

No.

// vendor/laravel/framework/src/Illuminate/Filesystem/FilesystemAdapter.php

/**
     * Create a directory.
     *
     * @param  string  $path
     * @return bool
     */
    public function makeDirectory($path)
    {
        return $this->driver->createDir($path);
    }

// vendor/league/flysystem/src/Adapter/Ftp.php:332
/**
     * @inheritdoc
     */
    public function createDir($dirname, Config $config)
    {
        $connection = $this->getConnection();
        $directories = explode('/', $dirname);

        foreach ($directories as $directory) {
            if (false === $this->createActualDirectory($directory, $connection)) {
                $this->setConnectionRoot();

                return false;
            }

            ftp_chdir($connection, $directory);
        }

        $this->setConnectionRoot();

        return ['type' => 'dir', 'path' => $dirname];
    }

PS: In general, not for the case with FTP, the rights are set by the value of the 'visibility' parameter , which has the default value of public :
// vendor/league/flysystem/src/Adapter/Local.php:34
/**
     * @var array
     */
    protected static $permissions = [
        'file' => [
            'public'  => 0644,
            'private' => 0600,
        ],
        'dir'  => [
            'public'  => 0755,
            'private' => 0700,
        ],
    ];

// vendor/league/flysystem/src/Adapter/Local.php:368

/**
     * @inheritdoc
     */
    public function createDir($dirname, Config $config)
    {
        $location = $this->applyPathPrefix($dirname);
        $umask = umask(0);
        $visibility = $config->get('visibility', 'public');

        if ( ! is_dir($location) && ! mkdir($location, $this->permissionMap['dir'][$visibility], true)) {
            $return = false;
        } else {
            $return = ['path' => $dirname, 'type' => 'dir'];
        }

        umask($umask);

        return $return;
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question