Yu-Gi-Oh! Deck Building and Card Inventory Management web interface written in Common Lisp, utilizing HTMX.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.4KB

  1. #|
  2. # File Attachments
  3. Attachment class for saving metadata into RDBMS
  4. See MITO-ATTACHMENT for more information: <https://github.com/fukamachi/mito-attachment>
  5. TODO AWS Storage / CC API Upload?
  6. Here's the bit of code for the FILEs:
  7. ;; (destructuring-bind (content filename content-type)
  8. ;; file
  9. ;; (if (and (eq (type-of content) 'flex::vector-input-stream)
  10. ;; (> (length (flex::vector-stream-vector content)) 0))
  11. ;; ...))
  12. |#
  13. (in-package #:cl-deck-builder2.models.attachment)
  14. (defclass attachment (mito-attachment:attachment) ()
  15. (:metaclass registered-table-class))
  16. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  17. (defun create-attachment (content file-key content-type)
  18. "Use CREATE-DAO to construct a new ATTACHMENT instance. Return the instance if successful, NIL otherwise."
  19. (create-dao 'attachment
  20. :content content
  21. :file-key file-key
  22. :content-type content-type))
  23. (defun attachment-valid-p (file)
  24. "Helper function. Ensure FILE data from Caveman has valid:
  25. - Type: 'FLEX::VECTOR-INPUT-STREAM
  26. - Filename: Length > 0
  27. - File Length: Content Length > 0"
  28. (destructuring-bind (content filename content-type)
  29. file
  30. ;; XXX Don't ignore content type?
  31. (declare (ignore content-type))
  32. (and (eq (type-of content) 'flex::vector-input-stream)
  33. (> (length (flex::vector-stream-vector content)) 0)
  34. (> (length filename) 0))))