github.com/olivere/camlistore@v0.0.0-20140121221811-1b7ac2da0199/clients/curl/upload-file.pl (about)

     1  #!/usr/bin/perl
     2  #
     3  # Lame upload script for development testing only.  Doesn't do the
     4  # stat step and hard-codes the Go server's upload path (not
     5  # conformant to spec).
     6  
     7  use strict;
     8  my $file = shift or die
     9      "Usage: upload-file.pl: <file>";
    10  -r $file or die "$file isn't readable.";
    11  -f $file or die "$file isn't a file.";
    12  
    13  die "bogus filename" if $file =~ /[ <>&\!]/;
    14  
    15  my $sha1 = `sha1sum $file`;
    16  chomp $sha1;
    17  $sha1 =~ s/\s.+//;
    18  
    19  system("curl", "-u", "foo:foo", "-F", "sha1-$sha1=\@$file",
    20         "http://127.0.0.1:3179/bs/camli/upload") and die "upload failed.";
    21  print "Uploaded http://127.0.0.1:3179/bs/camli/sha1-$sha1\n";