Subclass of +Entity? for storing binary or large text data in separate file.
Example of relation definition:
(class +C +Entity) (rel r (+Blob))
Example of gui element to display text data:
(gui '(+BlobField) '(r : home obj) 70 25)
There is also +RteField which can be used to edit blob text data.
It is probably useful to name the blob something like jpg instead of r.
Example of gui element to manage image data:
(prog (gui '(+Able +UpField) '(not (: home obj r)) 45) (gui '(+Button) '(if (: home obj r) ,"Uninstall" ,"Install") '(if (: home obj r) (ask ,"Uninstall Picture?" (put!> (: home top 1 r) 'r NIL) ) (let? F (val> (field -1)) (blob! (: home obj) 'r (tmp F)) ) ) ) )
Example of gui element to display image data:
(when (: home obj r) (<p> NIL (<img> (allow (blob (: home obj) 'r)) ,"Picture")) )
The following functions can be quite useful too:
(de fempty (F) (use C (in F (loop (NIL (setq C (char)) T) (T (not (member C (rlog: can't exec chop " ^I^M^J"))) NIL))))) (de blob? (Obj Var) (when (and Obj (get Obj Var)) (let B (blob Obj Var) (when (and (info B) (not (fempty B))) B))))
The blob? function returns the blob file name only if the object has the blob slot, the blob file exists and contains something (not whitespace only). If the blob does not contain any useful data, it might be better not to store it in the first place though.
ToDo what about checking the expected image type on upload?
ToDo what about checking upload file size limit?
This page is linked from: gui classes +RteField
Revisions: View source XHTMLV | RSSV
picoWiki pages can be edited by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively