public function downloadFile($pathFrom, $pathTo)
    {
        if ( ! $remoteStream = @fopen("ssh2.sftp://{$this->ftpConnection}/{$pathFrom}", 'r')) {
            throw new SftpRemoteFileException("Unable to open remote: '{$pathFrom}'.");
        }

        // ensure that local file may be created
        if ( ! is_dir(dirname($pathTo))) {

            $this->files->makeDirectory(dirname($pathTo), static::DIRECTORY_CREATE_MODE, true, true);
        }

        if ( ! $localStream = @fopen($pathTo, 'w')) {

            throw new SftpLocalFileException("Unable to open local file: '{$pathTo}'.");
        }

        // write from our remote stream to our local stream

        if ($this->chunking) {

            $bytesRead = 0;

            while ( ! feof($remoteStream)) {

                $buffer = fread($remoteStream, $this->chunkSize);
                $bytesRead += strlen($buffer);

                if (fwrite($localStream, $buffer) === false) {

                    throw new SftpLocalFileException("Unable to write to local file: '{$pathTo}'.");
                }
            }

        } else {
            // just read the entire stream at once

            $buffer    = stream_get_contents($remoteStream);
            $bytesRead = strlen($buffer);

            if (fwrite($localStream, $buffer) === false) {

                throw new SftpLocalFileException("Unable to write to local file: '{$pathTo}'.");
            }

        }


        unset($buffer);

        fclose($localStream);
        fclose($remoteStream);

        event( new SshFileDownloaded(basename($pathFrom), $pathTo, $bytesRead) );

        return $bytesRead;
    }