diff --git a/examples/cl-repl/lisp/upload-download.lisp b/examples/cl-repl/lisp/upload-download.lisp index 9166f1b..15587a4 100644 --- a/examples/cl-repl/lisp/upload-download.lisp +++ b/examples/cl-repl/lisp/upload-download.lisp @@ -3,12 +3,11 @@ (in-package :s-http-server) (defvar *web-server* nil) - -(defconstant +buffer-length+ 8192) - (defvar *empty-line* #.(map 'vector 'char-code (list #\Return #\Linefeed #\Return #\Linefeed))) +(defconstant +buffer-length+ 8192) + (defun form-data-filename (data start end) "Searches for 'filename=' in current form data field header." (let ((p1 (search #.(x:string-to-bytes "filename=\"") @@ -29,8 +28,8 @@ ;; don't read past end, would block http connection :for pos = (read-sequence buffer stream :end (min +buffer-length+ (- content-length index))) - do (adjust-array content (+ index pos)) - (replace content buffer :start1 index :end2 pos) + :do (adjust-array content (+ index pos)) + (replace content buffer :start1 index :end2 pos) :while (< index content-length)) ;; loop through all form-data and save file(s) (x:while-it (search boundary content :start2 start) @@ -105,12 +104,14 @@ it saves uploaded files on the server." "Creates a *.zip file of passed directory, _not_ including the directory name." (zip:zip (merge-pathnames zip-file) (probe-file directory) - :if-exists :supersede)) + :if-exists :supersede) + zip-file) (defun unzip (zip-file &optional directory) "Extracts (previously uploaded) *.zip file." (zip:unzip (merge-pathnames zip-file) (probe-file (or directory ".")) - :if-exists :supersede)) + :if-exists :supersede) + zip-file) (export (list 'zip 'unzip)) diff --git a/examples/cl-repl/readme.md b/examples/cl-repl/readme.md index e0b4aff..4ecf38c 100644 --- a/examples/cl-repl/readme.md +++ b/examples/cl-repl/readme.md @@ -98,7 +98,9 @@ port (mind the trailing `/`): http://192.168.1.x:1701/ ``` Now you can upload either a whole directory, or a single file. The files will -be stored in `[Home]/uploads/`. +be stored in `[Home]/uploads/`. Note that different browsers may behave +differently when uploading (recursive) directories (seems to work best with +either Firefox or Chromium based browsers). You may also upload a zip file, which can then be unzipped using: ``` diff --git a/examples/cl-repl/www/index.html b/examples/cl-repl/www/index.html index 1d7d703..b4881b9 100644 --- a/examples/cl-repl/www/index.html +++ b/examples/cl-repl/www/index.html @@ -10,10 +10,10 @@ -

Upload files to CL REPL app

+

Upload files to REPL app

- Whole Directory + Whole Directory (recursive in Firefox/Chromium)

@@ -26,6 +26,19 @@

- Files are saved in [Home]/uploads/. + + Files are saved in [Home]/uploads/. + +