Skip to content

Commit

Permalink
added download
Browse files Browse the repository at this point in the history
  • Loading branch information
sage-service-user committed Mar 6, 2014
1 parent b0e0e78 commit 0f00206
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
6 changes: 3 additions & 3 deletions libs/SHOCK/Client.pm
Expand Up @@ -261,9 +261,9 @@ sub download_to_path {
print STDERR "[error] missing node or path\n";
return undef;
}
if ($self->transport_method eq 'shock-client') {
return $self->_download_shockclient($node, $path);
}
#if ($self->transport_method eq 'shock-client') {
# return $self->_download_shockclient($node, $path);
#}

my $content = undef;
eval {
Expand Down
30 changes: 30 additions & 0 deletions utils/shockclient.pl
Expand Up @@ -48,6 +48,7 @@ sub shock_upload {
[ 'show=s' , ""],
[ 'delete=s' , ""],
[ 'query=s' , ""],
[ 'download=s' , ""],
[ 'clean_tmp' , ""],
# '',
# 'Options:',
Expand Down Expand Up @@ -117,6 +118,35 @@ sub shock_upload {



exit(0);
} elsif (defined($value = $h->{"download"})) {


my @nodes = split(',', $value);


foreach my $node (@nodes) {

my $view_response = $shock->get('node/'.$node);
print Dumper($view_response);
#exit(0);

my $filename = $view_response->{'data'}->{'file'}->{'name'};
unless (defined $filename) {
die "filename not defined, cannot save.";
}

if (-e $filename) {
die "file \"$filename\" already exists";
}


my $response = $shock->download_to_path($node, $filename);
print Dumper($response);
}



exit(0);

} elsif (defined($h->{"clean_tmp"})) {
Expand Down

0 comments on commit 0f00206

Please sign in to comment.