Closed knobo closed 9 years ago
I see. https://github.com/fukamachi/caveman/issues/6
The version I downloaded from quicklisp did not include include that fix. (I'm nut sure what the directory name means. clack-20150302-git ) I will update my distribution.
Hi, how do you actually use download and save the file to your local server?
You could try something like this:
(defparameter *file-storage-directory* #p"/var/www/images/")
(defroute ("/upload-image" :method :post) (&key |file|)
(let ((filename (gethash "filename" (second |file|)))
(data (slot-value (first |file|) 'flexi-streams::vector)))
(with-open-file (s (merge-pathnames filename *file-storage-directory*)
:if-does-not-exist :create
:if-exists :supersede :direction :output
:element-type '(unsigned-byte 8))
(write-sequence data s)))
(return-some-result-to-browser))
I'm planning to do something like this in the future (I have not tested it yet):
(setf *image-storage*
(make-instance 'disk-storage
:bucket "file-upload-example"
:directory #P"/tmp/attachment/"))
(defroute ("/upload-image" :method :post) (&key |file|)
(let ((filename (gethash "filename" (second |file|)))
(data (first |file|))
(mito-attachment:*storage* *image-storage*))
(mito:create-dao 'image :content data)
(return-some-result-to-browser)))
Hi,
How does one upload files to caveman2 I have this simple form, but I'm not able to get the contets.
if caveman2 can not do this, can I inject a hunchentoot handler that does that part?