[hunchentoot-devel] Preventing users to upload too big files
Andrei Stebakov
lispercat at gmail.com
Sat Sep 13 22:55:46 UTC 2008
I wonder what's the best way to handle the case when a user tries to upload
a very large file.
Basically we need to stop execution before it gets to the
parse-rfc2388-form-data and report the problem to the user.
I can think of placing some function call inside request's constructor
(defmethod initialize-instance :after ((request request) &rest init-args)
Something like:
(let* ((check (find-symbol "CHECK-FILE-SIZE" :your-package))
(header-value (find-symbol "HEADER-VALUE" :drakma))
(length (parse-integer (funcall header-value :content-length
headers-in))))
(funcall check length))
Inside function check-file-size you would raise an error if the file is too
big.
The problem is that this error gets handled by the lisp debugger and I can't
propagate it to the user.
Another thing, it's a dirty hack, what's the better way of doing this?
Thank you,
Andrew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/tbnl-devel/attachments/20080913/06be8f1c/attachment.html>
More information about the Tbnl-devel
mailing list