I've verified that the uploadToken value is consistent between calls to the Transfer object. The error is occurring during the second pass of the for loop below.
sub AppendFile {
#Takes Upload Token, Source File Name, Destination File Name, No Of bytes to Upload on each iteration and the expected response code as parameters.
########################## Method Invocation Parameters###########################
my ($uploadToken,$sourceFile,$destFile,$expected,%options,$AppendFile,$trueFlag,$falseFlag);
my ($res,$req,$bytesRead);
########################## File Variables ########################################
my($fileSize, $noOfBytes,$content,$fileData,$endOfFile);
($uploadToken,$sourceFile,$destFile,$noOfBytes,$expected)=@_;
%options = (proxy=>'http://node1.nirvanix.com/ws/transfer.asmx',
uri=>'http://transfer.nirvanix.com/ws/Transfer',
on_action=>sub {join '/','http://transfer.nirvanix.com/ws/Transfer',$_[1]});
$AppendFile = SOAP::Data->name('AppendFile')->attr({xmlns=>'http://transfer.nirvanix.com/ws/Transfer'});
$destFile = SOAP::Data->name(path=>$destFile)->uri('http://transfer.nirvanix.com/ws/Transfer');
$trueFlag = SOAP::Data->name(endOfFile=>'true')->uri('http://transfer.nirvanix.com/ws/Transfer');
$falseFlag = SOAP::Data->name(endOfFile=>'false')->uri('http://transfer.nirvanix.com/ws/Transfer');
$uploadToken= SOAP::Data->name(uploadToken=>$uploadToken)->uri('http://transfer.nirvanix.com/ws/Transfer');
$req = SOAP::Lite->new(%options);
if (-e $sourceFile) {
print "File Exists \n";
my $fileSize = stat("$sourceFile")->size;
print "Size: $fileSize\n";
if ($fileSize>0) {
open (INFILE,'<',$sourceFile)||die "Unable to open file\n";
binmode(INFILE);
for (my $j=$noOfBytes;$j<$fileSize;$j+=$noOfBytes) {
print "In For\n";
$bytesRead=read(INFILE,$fileData,$noOfBytes);
$fileData=SOAP::Data->name(fileData=>$fileData)->type('base64')->uri('http://transfer.nirvanix.com/ws/Transfer');
$res = $req->call($AppendFile,$uploadToken,$destFile,$fileData,$falseFlag);
if ($res->fault) {
print " \t################################# In For Loop ###############################\n";
print $res->faultstring,"\n";
last;
}
}
if (!$res->fault) {
$bytesRead=read(INFILE,$fileData,$noOfBytes);
$fileData=SOAP::Data->name(fileData=>$fileData)->type('base64')->uri('http://transfer.nirvanix.com/ws/Transfer');
$res = $req->call($AppendFile,$uploadToken,$destFile,$fileData,$trueFlag);
}
if ($res->fault) {
print $res->faultstring,"\n";
}
close INFILE;
}
else {
print ("No Data In File");
}
}
else {
print " File Doesn't Exist\n";
}
}