> *) How can i get both the new unique name and the multipart file name
> into the file slot, maybe as a list of values?
Wait.. that code I posted is a bit off. You do need to subclass the
parser, but the both-names slot isn't necessary.
Try this:
(defclass custom-file-upload-parser (file-upload-parser)
()
(:documentation "A parser that returns a plist of the disk file
name, the original browser name, and the mime type"))
(defmethod parse-view-field-value ((parser custom-file-upload-parser)
value obj
(view form-view) (field form-view-field)
&rest args)
(declare (ignore args))
(when (null value)
(return-from parse-view-field-value (values t nil)))
(when (stringp value)
(error "The value of the upload field is incorrect. Please turn on
multipart requests and turn off ajax."))
(flet ((octet-string->utf-8 (s)
"Kludge to fix librfc2388 bug."
(hunchentoot::octets-to-string
(map 'vector
(lambda (c)
(let ((x (char-int c)))
(assert (and (not (minusp x))
(< x 256)))
x))
s))))
(let* ((temp-path (first value))
(mime-type (third value))
(browser-name (octet-string->utf-8 (second value)))
(disk-file-name (hunchentoot::create-random-string)))
(copy-file temp-path
(merge-pathnames disk-file-name
(file-upload-parser-upload-directory
parser))
:if-exists :supersede)
(values t value (list :disk-file disk-file-name :original-name
browser-name :mime-type mime-type)))))
--
You received this message because you are subscribed to the Google Groups
"weblocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/weblocks?hl=en.