public function create(LibraryType $library, DirectoryItem $item): bool
    {
        // do not allow empty paths
        if (empty($item->path) || empty($item->name)) {
            return false;
        }

        $uri = sprintf(
            '%s/repos/%s/file/?p=%s',
            $this->clipUri($this->client->getConfig('base_uri')),
            $library->id,
            $this->urlEncodePath($item->path . $item->name)
        );

        $response = $this->client->request(
            'POST',
            $uri,
            [
                'headers'   => ['Accept' => 'application/json'],
                'multipart' => [
                    [
                        'name'     => 'operation',
                        'contents' => 'create',
                    ],
                ],
            ]
        );

        return $response->getStatusCode() === 201;
    }
public function create(LibraryType $library, DirectoryItem $item): bool
    {
        // do not allow empty paths
        if (empty($item->path) || empty($item->name)) {
            return false;
        }

        $uri = sprintf(
            '%s/repos/%s/file/?p=%s',
            $this->clipUri($this->client->getConfig('base_uri')),
            $library->id,
            $this->urlEncodePath($item->path . $item->name)
        );

        $response = $this->client->request(
            'POST',
            $uri,
            [
                'headers'   => ['Accept' => 'application/json'],
                'multipart' => [
                    [
                        'name'     => 'operation',
                        'contents' => 'create',
                    ],
                ],
            ]
        );

        return $response->getStatusCode() === 201;
    }
public function create ( LibraryType $ library , DirectoryItem $ item ) : bool { // do not allow empty paths if ( empty ( $ item -> path ) || empty ( $ item -> name ) ) { return false ; } $ uri = sprintf ( '%s/repos/%s/file/?p=%s' , $ this -> clipUri ( $ this -> client -> getConfig ( 'base_uri' ) ) , $ library -> id , $ this -> urlEncodePath ( $ item -> path . $ item -> name ) ) ; $ response = $ this -> client -> request ( 'POST' , $ uri , [ 'headers' => [ 'Accept' => 'application/json' ] , 'multipart' => [ [ 'name' => 'operation' , 'contents' => 'create' , ] , ] , ] ) ; return $ response -> getStatusCode ( ) === 201 ; }
Create empty file on Seafile server

@param LibraryType   $library Library instance
@param DirectoryItem $item    Item instance

@return bool
@throws \GuzzleHttp\Exception\GuzzleException
Create empty file on Seafile server