> > *) How do i access the uploaded file?
> > (I see that the method (defmethod parse-view-field-value ((parser file-
> > upload-parser) value obj...) returns multiple values including the
> > list of values from the multi-part, and the local file name. I dont
> > know how these are stored in the 'file' slot in the example above, or
> > how i would access them).
>
> Ok, parse-view-field-value sets the field to the file name.
> I want to make a :unique file name, and access both the :unique name,
> as well as the original name sent in the multipart/.
In general, the view mechanism works as follows:
a. In the default defview, the fieldspec has args
{ :writer :reader :parse-as :present-as }
There are defaults for all of these, and you can specify your own.
b. The writer function gets the object (for which the view is
declared) and the field-value as returned by the :parse-as function,
that is, the parsed value..
c. The parse-as function gets the string representation used in html
(eg, see html select element or checkboxes) and turns it into a normal
lisp value..
d. By default the writer simply writes the parsed value into the slot
named by the field name..
You can view the gory details by seeing the update-object-view-from-
request function (M-. if you're using slime).
In your specific case, since at step d. the writer writes the parsed
value, the final file name gets seen by the default writer (afaik)
which dutifully writes it into the slot.
Now since all the above are methods on form-view-field, you can also
use normal mop-ery on them, and get more creative by subclassing the
form-view-field etc., but that's a topic you'll probably only need to
explore when you want to make a radically different form mechanism.)
> *) How can i get both the new unique name and the multipart file name
> into the file slot, maybe as a list of values?
Post code if you can. It doesn't have to be a minimal test case, but
every little bit helps!
If I understand what you're trying to do correctly, subclass file-
upload-parser, write a defmethod for parse-view-field-value
specialized on your subclass, and where the default method for file-
upload-parser considers only the first item in the values list:
let* ((temp-path (first value)) -- use all the values, and where it
returns the parsed name as the file-name, return a list or cons
instead, which'll then get stored into the slot of your object.
that is, replace (values t value file-name) with approximately
(values t value (cons file-name mime-type browser multipart)))
At least, writing the defmethod above and/or putting break's into the
default method in file-upload.lisp [1] will let you see what
hunchentoot makes available to you (afaik, it has to be in the same
request, hunchentoot deletes the uploaded file from /tmp/hunchentoot/
when the request is done).
[1] I mean this one: parse-view-field-value ((parser file-upload-
parser) value obj ..
--
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.