public function copy(
        LibraryType $srcLibrary,
        array $srcPaths,
        LibraryType $dstLibrary,
        string $dstDirectoryPath,
        int $operation = self::OPERATION_COPY
    ): bool {
        // do not allow empty paths
        if (empty($srcPaths) || empty($dstDirectoryPath)) {
            return false;
        }

        $operationMode = $operation === self::OPERATION_MOVE ? 'move' : 'copy';

        // get the source folder path
        // this path must be the same for all files!
        $srcFolderPath = dirname($srcPaths[0]);

        $dstFileNames = $this->preparePaths($srcFolderPath, $srcPaths);

        if (empty($dstFileNames)) {
            return false;
        }

        $srcFolderPath = str_replace("\\", "/", $srcFolderPath); // windows compatibility

        $uri = sprintf(
            '%s/repos/%s/fileops/%s/?p=%s',
            $this->clipUri($this->client->getConfig('base_uri')),
            $srcLibrary->id,
            $operationMode,
            $srcFolderPath
        );

        $response = $this->client->request(
            'POST',
            $uri,
            [
                'headers'   => ['Accept' => 'application/json'],
                'multipart' => [
                    [
                        'name'     => 'file_names',
                        'contents' => $dstFileNames,
                    ],
                    [
                        'name'     => 'dst_repo',
                        'contents' => $dstLibrary->id,
                    ],
                    [
                        'name'     => 'dst_dir',
                        'contents' => $dstDirectoryPath,
                    ],
                ],
            ]
        );

        return $response->getStatusCode() === 200;
    }
public function copy(
        LibraryType $srcLibrary,
        array $srcPaths,
        LibraryType $dstLibrary,
        string $dstDirectoryPath,
        int $operation = self::OPERATION_COPY
    ): bool {
        // do not allow empty paths
        if (empty($srcPaths) || empty($dstDirectoryPath)) {
            return false;
        }

        $operationMode = $operation === self::OPERATION_MOVE ? 'move' : 'copy';

        // get the source folder path
        // this path must be the same for all files!
        $srcFolderPath = dirname($srcPaths[0]);

        $dstFileNames = $this->preparePaths($srcFolderPath, $srcPaths);

        if (empty($dstFileNames)) {
            return false;
        }

        $srcFolderPath = str_replace("\\", "/", $srcFolderPath); // windows compatibility

        $uri = sprintf(
            '%s/repos/%s/fileops/%s/?p=%s',
            $this->clipUri($this->client->getConfig('base_uri')),
            $srcLibrary->id,
            $operationMode,
            $srcFolderPath
        );

        $response = $this->client->request(
            'POST',
            $uri,
            [
                'headers'   => ['Accept' => 'application/json'],
                'multipart' => [
                    [
                        'name'     => 'file_names',
                        'contents' => $dstFileNames,
                    ],
                    [
                        'name'     => 'dst_repo',
                        'contents' => $dstLibrary->id,
                    ],
                    [
                        'name'     => 'dst_dir',
                        'contents' => $dstDirectoryPath,
                    ],
                ],
            ]
        );

        return $response->getStatusCode() === 200;
    }
public function copy ( LibraryType $ srcLibrary , array $ srcPaths , LibraryType $ dstLibrary , string $ dstDirectoryPath , int $ operation = self :: OPERATION_COPY ) : bool { // do not allow empty paths if ( empty ( $ srcPaths ) || empty ( $ dstDirectoryPath ) ) { return false ; } $ operationMode = $ operation === self :: OPERATION_MOVE ? 'move' : 'copy' ; // get the source folder path // this path must be the same for all files! $ srcFolderPath = dirname ( $ srcPaths [ 0 ] ) ; $ dstFileNames = $ this -> preparePaths ( $ srcFolderPath , $ srcPaths ) ; if ( empty ( $ dstFileNames ) ) { return false ; } $ srcFolderPath = str_replace ( "\\" , "/" , $ srcFolderPath ) ; // windows compatibility $ uri = sprintf ( '%s/repos/%s/fileops/%s/?p=%s' , $ this -> clipUri ( $ this -> client -> getConfig ( 'base_uri' ) ) , $ srcLibrary -> id , $ operationMode , $ srcFolderPath ) ; $ response = $ this -> client -> request ( 'POST' , $ uri , [ 'headers' => [ 'Accept' => 'application/json' ] , 'multipart' => [ [ 'name' => 'file_names' , 'contents' => $ dstFileNames , ] , [ 'name' => 'dst_repo' , 'contents' => $ dstLibrary -> id , ] , [ 'name' => 'dst_dir' , 'contents' => $ dstDirectoryPath , ] , ] , ] ) ; return $ response -> getStatusCode ( ) === 200 ; }
Copy multiple files or folders

@param LibraryType $srcLibrary       Source library object
@param array       $srcPaths         Array with file/folder paths (they must be in the same folder)
@param LibraryType $dstLibrary       Destination library object
@param string      $dstDirectoryPath Destination directory Path
@param int         $operation        self::OPERATION_COPY or self::OPERATION_MOVE

@return bool
@throws \GuzzleHttp\Exception\GuzzleException
Copy multiple files or folders