filestack/mixins/CommonMixin.php
protected function sendDownload($url, $destination, $security = null)
    {
        if (is_dir($destination)) {
            // destination is a folder
            $json = $this->sendGetMetaData($url, ["filename"], $security);
            $remote_filename = $json['filename'];
            $destination .= $remote_filename;
        }

        // sign url if security is passed in
        if ($security) {
            $url = $security->signUrl($url);
        }

        # send request
        $options = ['sink' => $destination];

        $url .= '&dl=true';
        $response = $this->sendRequest('GET', $url, $options);
        $status_code = $response->getStatusCode();

        // handle response
        if ($status_code !== 200) {
            throw new FilestackException($response->getBody(), $status_code);
        }

        return true;
    }
protected function sendDownload($url, $destination, $security = null)
    {
        if (is_dir($destination)) {
            // destination is a folder
            $json = $this->sendGetMetaData($url, ["filename"], $security);
            $remote_filename = $json['filename'];
            $destination .= $remote_filename;
        }

        // sign url if security is passed in
        if ($security) {
            $url = $security->signUrl($url);
        }

        # send request
        $options = ['sink' => $destination];

        $url .= '&dl=true';
        $response = $this->sendRequest('GET', $url, $options);
        $status_code = $response->getStatusCode();

        // handle response
        if ($status_code !== 200) {
            throw new FilestackException($response->getBody(), $status_code);
        }

        return true;
    }
protected function sendDownload ( $ url , $ destination , $ security = null ) { if ( is_dir ( $ destination ) ) { // destination is a folder $ json = $ this -> sendGetMetaData ( $ url , [ "filename" ] , $ security ) ; $ remote_filename = $ json [ 'filename' ] ; $ destination .= $ remote_filename ; } // sign url if security is passed in if ( $ security ) { $ url = $ security -> signUrl ( $ url ) ; } # send request $ options = [ 'sink' => $ destination ] ; $ url .= '&dl=true' ; $ response = $ this -> sendRequest ( 'GET' , $ url , $ options ) ; $ status_code = $ response -> getStatusCode ( ) ; // handle response if ( $ status_code !== 200 ) { throw new FilestackException ( $ response -> getBody ( ) , $ status_code ) ; } return true ; }
Download a file to specified destination given a url

@param string            $url            Filestack file url
@param string            $destination    destination filepath to save to,
can be a directory name
@param FilestackSecurity $security       Filestack security object if
security settings is turned on

@throws FilestackException   if API call fails, e.g 404 file not found

@return bool (true = download success, false = failed)
Download a file to specified destination given a url