Skip to content

Commit

Permalink
add downloadFile
Browse files Browse the repository at this point in the history
  • Loading branch information
miziomon committed Mar 17, 2014
1 parent 6dd055d commit 2eb7f2f
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ vendor/
deployer.phar
pages/
.idea/
/nbproject/private/
Binary file added composer.phar
Binary file not shown.
7 changes: 7 additions & 0 deletions nbproject/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include.path=${php.global.include.path}
php.version=PHP_53
source.encoding=UTF-8
src.dir=.
tags.asp=false
tags.short=false
web.root=.
9 changes: 9 additions & 0 deletions nbproject/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.php.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/php-project/1">
<name>deployer</name>
</data>
</configuration>
</project>
14 changes: 14 additions & 0 deletions src/Deployer/Remote/Remote.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,18 @@ public function uploadFile($from, $to)
}
$this->sftp->put($to, $from, NET_SFTP_LOCAL_FILE);
}

/**
* download file from remote in current directory
* @param type $from
* @param type $to
*/
public function downloadFile($from, $to)
{


return $this->sftp->get($from, $to);


}
}
22 changes: 22 additions & 0 deletions src/Deployer/Tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,28 @@ public function upload($local, $remote)
}
}

public function download($remote , $local )
{
$this->checkConnected();

//$local = Path::normalize(realpath($local));
//$local = getcwd() . "/" . $local ;

$this->writeln( $local );

$this->writeln("Downloading file <info>$remote</info> to <info>$local</info>");
$status = $this->remote->downloadFile($remote , $local );

$this->writeln( "status:: " . $status );

if ( $status ) {
$this->writeln("Download complete");
} else {
throw new \RuntimeException("Download error ");
}

}

public function cd($directory)
{
$this->checkConnected();
Expand Down
11 changes: 11 additions & 0 deletions src/Deployer/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ function upload($from, $to)
Context::get()->upload($from, $to);
}

/**
*
* @param type $from
* @param type $to
*/
function download($from, $to)
{
Context::get()->download($from, $to);
}


/**
* Change current directory for whole connect session.
* @param string $directory
Expand Down

0 comments on commit 2eb7f2f

Please sign in to comment.