curl -i --data-binary "@./myFile.zip" -H "Content-Disposition: filename=myFile.zip" -H "Content-Type:application/zip" -H "X-Packaging:http://purl.org/net/sword-types/METSDSpaceSIP" -H "X-No-Op:false" -H "X-Verbose:true" http://myUsername:myPassword@my.host:port/path/to/script #### use LWP::UserAgent; my $host = 'my.host:port'; my $username = 'myUsername'; my $password = 'myPassword'; my $realm = 'theRealm'; my $sword_url = "http://$host/path/to/script"; my $filename = "myFile.zip"; my $file = ""; open(FILE, "$filename" ) or die('cant open input file'); binmode FILE; while() { $file .= $_; } close FILE; my $ua = LWP::UserAgent->new(); $ua->credentials( "$host", "$realm", "$username" => "$password" ); my $req = HTTP::Request->new( POST => $sword_url ); my $length = do {use bytes; length $file}; # Header information needed by the application $req->header( 'X-Packaging' => 'http://purl.org/net/sword-types/METSDSpaceSIP', 'X-No-Op' => 'false', 'X-Verbose' => 'true', 'Content-Disposition' => "filename=$filename" ); $req->content_type( 'application/zip' ); $req->content( $file ); $req->content_length($length); my $res = $ua->request($req); if ($res->is_success) { print $res->content; } else { print $res->status_line, "\n"; }