Handling uploads
I couldn't find any officially documented way to get uploads. After much digging, I figured out I need to (lack.request:make-request env) and then I can use (lack.request:request-parameters req). My code looks like this:
(let* ((params (lack.request:request-parameters req))
(file (cdr (assoc "file" params :test #'string=)))
(token (cadr (assoc "token" params :test #'string=))))
(destructuring-bind (input-stream params1 params2) file
(let ((filename (gethash "filename" params1))
(mimetype (gethash "content-type" params2)))
(make-file filename mimetype input-stream token)))
It works, but I feel like using private APIs. The parameters appear to be an alist, associating the parameter name with a list of things; to get the value of the token, for example, I need to use (cadr (assoc "token" params)). Also, for the file I get an in-memory stream and two hashes, one containing the file name and the other containing the content-type.
My question is, is this code future-proof, or is the API supposed to change? (or is there some better API that I failed to find?)
Lack.Request is an open API.
I agree with the structure isn't understandable very much, however, it's taken from Hunchentoot's. More useful helper function might be added, but the API (and its structure) won't be changed, I think.