Open asarch opened 3 years ago
Take a look at the flexi-stream docs, there are examples for streaming into files:
Can you please give me an example of a POST message handler with Caveman2?
Courtesy of Mr. Nilby@#lisp.FreeNode:
(defroute ("/" :method :POST) (&key _parsed)
(let ((uploaded-file-buffer (second (car _parsed)))
(file-name (format nil "static/~a" (third (car _parsed)))))
(with-open-file (file-stream file-name :direction :output :if-exists :supersede :element-type '(unsigned-byte 8))
(uiop:copy-stream-to-stream uploaded-file-buffer file-stream :element-type '(unsigned-byte 8))))
;;(loop :with byte
;; :while (setf byte (read-byte uploaded-file-buffer nil))
;; :do (write-byte byte file-stream))))
(redirect "/"))
How do you store in the server an uploaded file?
I mean, from this stream:
or from this?
And how?