Since it is possible in WebDMS to transfer a file (PDF or graphic file) to the archive server, it is also possible to do this via external control. In principle, the go_action&action=upload
command can be used for this. However, when you upload data, it is necessary to switch to 'POST' mode during communication with WebDMS (this is different from the GET mode that is normally used).
During the upload, you can include the uploadocr=x
and uploadbits=y
options in order to determine OCR definitions as well as scanning. Alternatively, you can also determine a scan definition containing the processing parameters directly during the upload. You use uploaddef=x
to select a specific scan definition, although the first scan definition is activated with 0
.
The following example demonstrates uploading a file to the web server in the Perl programming language. The comments should be of assistance even if you carry out the upload in a different programming language.
#!/usr/bin/perl # wcupload.pl -> demo script for uploading a document via web client # (c) 2008 by Archivista GmbH, Urs Pfister use strict; use LWP::UserAgent; # we work with UserAgent (our batch web browser) use HTTP::Cookies; # we need to work with cookies use HTTP::Request::Common qw(POST); # the post method must be imported my $fin = "/home/archivista/documentation_de.pdf"; # demo doc (our manual) my $pages = "1-5"; # pages to extract (so we don't wait too long) my $fout = "/tmp/eins.pdf"; # the finally file we want to import if (!-e $fout) { # create file with pdftk if it does not already exist system("pdftk $fin cat $pages output $fout"); } # server we use (link to webdms) my $server = "http://localhost/perl/avclient/index.pl"; # connection string (host,db,user,password) my $connect = "?host=localhost&db=archivista&uid=Admin&pwd=archivista"; my $www = LWP::UserAgent->new; # new www session # save the cookie for the corrent session $www->cookie_jar(HTTP::Cookies->new('file'=>'/tmp/cookies.lwp','autosave'=>1)); my $res = $www->get("$server$connect"); # connect to webdms if ($res->is_success) { if ($res->content) { # we got login # now upload a file, we use request method with POST my $res = $www->request(POST "$server", Content_Type => 'form-data', # multipart/form-data Content => [ # structure for our file MAX_FILE_SIZE => 134217728, # max. size (webdms won't accept more) upload => [ $fout, $fout ], # file to upload, file name to use go => 'go_action', # we need to call the go_action command action => 'upload', # inside of go_action we need to use upload uploadbits => 1, # 1=black/white, 8=gray, 24=color uploadocr => 27, # the desired ocr def (1-x, 27 does mean: no ocr) meta => "Titel:450", # filling in some meta keys is no problem ] ); if ($res->is_success) { # if we got a succes, file is uploaded print "file $fout uploaded\n"; } } }
Note: The above example runs in every ArchivistaBox. In principle, however, WebDMS can be addressed by any computer and it is even possible to work with encrypted access (HTTPS). You can find the program on the ArchivistaBox CD under /home/cvs/archivista/jobs
under the name wcupload.pl
.