public function get_link($url) {
        $ocsparams = [
            'path' => $url,
            'shareType' => ocs_client::SHARE_TYPE_PUBLIC,
            'publicUpload' => false,
            'permissions' => ocs_client::SHARE_PERMISSION_READ
            ];

        $response = $this->ocsclient->call('create_share', $ocsparams);
        $xml = simplexml_load_string($response);

        if ($xml === false ) {
            throw new \repository_nextcloud\request_exception(array('instance' => $this->get_name(),
                'errormessage' => get_string('invalidresponse', 'repository_nextcloud')));
        }

        if ((string)$xml->meta->status !== 'ok') {
            throw new \repository_nextcloud\request_exception(array('instance' => $this->get_name(), 'errormessage' => sprintf(
                '(%s) %s', $xml->meta->statuscode, $xml->meta->message)));
        }

        // Take the share link and convert it into a download link.
        return ((string)$xml->data[0]->url) . '/download';
    }
public function get_link($url) {
        $ocsparams = [
            'path' => $url,
            'shareType' => ocs_client::SHARE_TYPE_PUBLIC,
            'publicUpload' => false,
            'permissions' => ocs_client::SHARE_PERMISSION_READ
            ];

        $response = $this->ocsclient->call('create_share', $ocsparams);
        $xml = simplexml_load_string($response);

        if ($xml === false ) {
            throw new \repository_nextcloud\request_exception(array('instance' => $this->get_name(),
                'errormessage' => get_string('invalidresponse', 'repository_nextcloud')));
        }

        if ((string)$xml->meta->status !== 'ok') {
            throw new \repository_nextcloud\request_exception(array('instance' => $this->get_name(), 'errormessage' => sprintf(
                '(%s) %s', $xml->meta->statuscode, $xml->meta->message)));
        }

        // Take the share link and convert it into a download link.
        return ((string)$xml->data[0]->url) . '/download';
    }
public function get_link ( $ url ) { $ ocsparams = [ 'path' => $ url , 'shareType' => ocs_client :: SHARE_TYPE_PUBLIC , 'publicUpload' => false , 'permissions' => ocs_client :: SHARE_PERMISSION_READ ] ; $ response = $ this -> ocsclient -> call ( 'create_share' , $ ocsparams ) ; $ xml = simplexml_load_string ( $ response ) ; if ( $ xml === false ) { throw new \ repository_nextcloud \ request_exception ( array ( 'instance' => $ this -> get_name ( ) , 'errormessage' => get_string ( 'invalidresponse' , 'repository_nextcloud' ) ) ) ; } if ( ( string ) $ xml -> meta -> status !== 'ok' ) { throw new \ repository_nextcloud \ request_exception ( array ( 'instance' => $ this -> get_name ( ) , 'errormessage' => sprintf ( '(%s) %s' , $ xml -> meta -> statuscode , $ xml -> meta -> message ) ) ) ; } // Take the share link and convert it into a download link. return ( ( string ) $ xml -> data [ 0 ] -> url ) . '/download' ; }
Use OCS to generate a public share to the requested file.
This method derives a download link from the public share URL.

@param string $url relative path to the chosen file
@return string the generated download link.
@throws \repository_nextcloud\request_exception If nextcloud responded badly
Use OCS to generate a public share to the requested file . This method derives a download link from the public share URL .