Set the visibility for a file.

@param string $path
@param string $visibility

@return array|false file meta data

Aliyun OSS ACL value: 'default', 'private', 'public-read', 'public-read-write'
@throws \OSS\Core\OssException
19233
public function setVisibility($path, $visibility)
    {
        $location = $this->applyPathPrefix($path);
        $this->ossClient->putObjectAcl(
            $this->bucket,
            $location,
            ($visibility == 'public') ? 'public-read' : 'private'
        );
        return true;
    }
1041885
public function setPath($path)
    {
        if (!is_readable($path)) {
            throw new \InvalidArgumentException('The passed path is not readable: ' . $path);
        }

        $this->path = $path;
        $this->source = file_get_contents($path);

        return $this;
    }
81427
protected function getRawVisibility($path)
    {
        try {
            $acl = $this->getObject($path)->acl()->get(['entity' => 'allUsers']);
            return $acl['role'] === Acl::ROLE_READER ?
                AdapterInterface::VISIBILITY_PUBLIC :
                AdapterInterface::VISIBILITY_PRIVATE;
        } catch (NotFoundException $e) {
            // object may not have an acl entry, so handle that gracefully
            return AdapterInterface::VISIBILITY_PRIVATE;
        }
    }
931179
public function setVisibility($path, $visibility)
    {
        $path = Util::normalizePath($path);

        return (bool) $this->adapter->setVisibility($path, $visibility);
    }
1125673
public function setVisibility($path, $visibility)
    {
        $command = $this->s3Client->getCommand(
            'putObjectAcl',
            [
                'Bucket' => $this->bucket,
                'Key'    => $this->applyPathPrefix($path),
                'ACL'    => $visibility === AdapterInterface::VISIBILITY_PUBLIC ? 'public-read' : 'private',
            ]
        );

        try {
            $this->s3Client->execute($command);
        } catch (S3Exception $exception) {
            return false;
        }

        return compact('path', 'visibility');
    }
1021059
protected function getObjectACL($path)
    {
        $metadata = $this->getVisibility($path);

        return $metadata['visibility'] === AdapterInterface::VISIBILITY_PUBLIC ? OssClient::OSS_ACL_TYPE_PUBLIC_READ : OssClient::OSS_ACL_TYPE_PRIVATE;
    }
1156893
public function isVisibilityAllowed($visibility)
    {
        $visibilityAllowed = $this->getSettings()
            ? $this->getSettings()->getVisibility()
            : Settings::VISIBILITY_DEFAULT;

        return (bool) ($visibilityAllowed & $visibility);
    }
698510
public function getVisibility($path)
    {
        $recursive = false;
        $metadata = $this->getApi()->getTreeMetadata($path, $recursive);
        return $metadata[0];
    }
115404
public function setPath($path)
    {
        if (is_writable($path)) {
            $file = fopen($path, 'a+');
            fseek($file, -1, SEEK_END);
            if (fread($file, 1) != "\n") {
                fwrite($file, PHP_EOL);
            }
            fclose($file);
        }

        // should parse message incrementally from file
        $this->resource = mailparse_msg_parse_file($path);
        $this->stream = fopen($path, 'r');
        $this->parse();

        return $this;
    }
1368105
public static function setPermissions(string $path, int $mode = null)
    {
        $is_dir = is_dir($path);

        $current_uid = posix_getuid();
        $owner = @fileowner($path);
        if ($current_uid !== $owner)
            return;

        if (self::$file_group)
        {
            $current_gid = filegroup($path);
            $grpinfo = posix_getgrnam(self::$file_group);
            $wanted_gid = $grpinfo['gid'];
            if ($wanted_gid !== $current_gid)
            {
                try
                {
                    !@chgrp($path, self::$file_group);
                    clearstatcache(true, $path);
                }
                // @codeCoverageIgnoreStart
                // Impossible to test - this would require a RO file system
                catch (Throwable $e)
                {
                    throw new IOException(
                        "Could not set group on " . $path . " to " . self::$file_group
                    );
                }
                // @codeCoverageIgnoreEnd
            }
        }
        
        if ($mode === null)
            $mode = $is_dir ? self::$dir_mode : self::$file_mode;

        if (!empty($mode))
        {
            $perms = self::getPermissions($path);
            $current_mode = $perms['mode'];
            
            if ($mode !== $current_mode)
            {
                try
                {
                    @chmod($path, $mode);
                    clearstatcache(true, $path);
                }
                // @codeCoverageIgnoreStart
                // Impossible to test - this would require a RO file system
                catch (Throwable $e)
                {
                    throw new IOException(
                        "Could not set mode on " . $path . " to " . $mode
                    );
                }
                // @codeCoverageIgnoreEnd
            }
        }
    }
1347964
public static function decodeFromFile($path)
    {
        if (!file_exists($path)) {
            throw new \RuntimeException("File $path does not exist");
        }

        $buffer = file_get_contents($path);
        $object = self::decode($buffer);

        return $object;
    }
949911
public function update_visibility($visible = null) {
        if (is_bool($visible)) {
            $this->_visible = $visible;
        } else {
            $this->_visible = !$this->_visible;
        }
        return $this->update_visible();
    }
722320
public static function getVisibility(string $path)
    {
        clearstatcache(false, $path);
        $permissions = octdec(substr(sprintf('%o', fileperms($path)), -4));
        $visibility = $permissions & 0044 ? 'public' : 'private';

        return $visibility;
    }
1157974
public function initFromPath($path)
    {
        if ( ! file_exists($path)) {
            throw new \Intervention\Image\Exception\NotReadableException(
                "Unable to find file ({$path})."
            );
        }

        // get mime type of file
        $mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path);

        // define core
        switch (strtolower($mime)) {
            case 'image/png':
            case 'image/x-png':
                $core = @imagecreatefrompng($path);
                break;

            case 'image/jpg':
            case 'image/jpeg':
            case 'image/pjpeg':
                $core = @imagecreatefromjpeg($path);
                if (!$core) {
                    $core= @imagecreatefromstring(file_get_contents($path));
                }
                break;

            case 'image/gif':
                $core = @imagecreatefromgif($path);
                break;

            case 'image/webp':
            case 'image/x-webp':
                if ( ! function_exists('imagecreatefromwebp')) {
                    throw new \Intervention\Image\Exception\NotReadableException(
                        "Unsupported image type. GD/PHP installation does not support WebP format."
                    );
                }
                $core = @imagecreatefromwebp($path);
                break;

            default:
                throw new \Intervention\Image\Exception\NotReadableException(
                    "Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files."
                );
        }

        if (empty($core)) {
            throw new \Intervention\Image\Exception\NotReadableException(
                "Unable to decode image from file ({$path})."
            );
        }

        $this->gdResourceToTruecolor($core);

        // build image
        $image = $this->initFromGdResource($core);
        $image->mime = $mime;
        $image->setFileInfoFromPath($path);

        return $image;
    }
1152304
public function setVisibility($path, $visibility)
    {
        $this->filesystem->setVisibility(
            $this->path($path),
            $visibility
        );
    }
1052851
public function setDefaultVisibility(string $visibility): void
    {
        if (null === $this->get) {
            $this->get = $visibility;
        }

        if (null === $this->set) {
            $this->set = $visibility;
        }

        if (null === $this->add) {
            $this->add = $visibility;
        }

        if (null !== $this->remove) {
            return;
        }

        $this->remove = $visibility;
    }
734375
public function getVisibility(string $path): string
    {
        $location = $this->applyBasePath($path);
        clearstatcache(false, $location);
        $permission = octdec(substr(sprintf('%o', fileperms($location)), -4));

        return $permission & 0044 ? self::VIS_PUB : self::VIS_PRI;
    }