Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 1e729e7a01
Fetching contributors…

Cannot retrieve contributors at this time

57 lines (45 sloc) 1.345 kb
#!/usr/bin/perl
use File::Basename;
use LWP::UserAgent;
use File::Slurp;
my $gzipFile = shift;
my $extractInto = dirname($gzipFile);
print "Extracting files...";
`tar -zxvf $gzipFile -C $extractInto`;
print "finished\n";
opendir(my $extractDH, $extractInto);
my $ua = LWP::UserAgent->new;
$ua->agent("corona test loader");
my $i = 1;
while(my $file = readdir $extractDH) {
if($i % 100 == 0) {
print "Loaded $i documents\n";
}
if($file =~ /\.json$/) {
my $req = HTTP::Request->new(PUT => "http://localhost:8100/json/store/$file");
my $content = read_file($extractInto . "/" . $file);
$req->content($content);
my $res = $ua->request($req);
if($res->is_success) {
unlink $extractInto . "/" . $file;
}
else {
print "Error: ", $res->status_line, "\n";
}
$i++;
}
if($file =~ /\.xml$/) {
my $req = HTTP::Request->new(PUT => "http://localhost:8100/xml/store/$file");
my $content = read_file($extractInto . "/" . $file);
$req->content($content);
my $res = $ua->request($req);
if($res->is_success) {
unlink $extractInto . "/" . $file;
}
else {
print "Error: ", $res->status_line, "\n";
}
$i++;
}
}
closedir($extractDH);
Jump to Line
Something went wrong with that request. Please try again.