The following example demonstrates accessing an uploaded file. This simple server accesses the file named “file” and returns it’s sha1sum and file name.
;;; file-upload.el --- use an uploaded file (ws-start '(((:POST . ".*") . (lambda (request) (with-slots (process headers) request (ws-response-header process 200 '("Content-type" . "text/plain")) (let ((file (cdr (assoc "file" headers)))) (process-send-string process (concat (sha1 (cdr (assoc 'content file))) " " (cdr (assoc 'filename file)) "\n"))))))) 9008)
A file may be uploaded from an HTML form, or using the
program as in the following example.
$ curl -s -F file=usr/share/emacs/24.3/etc/COPYING localhost:9008 8624bcdae55baeef00cd11d5dfcfa60f68710a02 COPYING $ sha1sum /usr/share/emacs/24.3/etc/COPYING 8624bcdae55baeef00cd11d5dfcfa60f68710a02 /usr/share/emacs/24.3/etc/COPYING