KPB-US / badgeulator

employee identification badge printing system
1 stars 1 forks source link

Can't load font artifact #108

Closed bjh45964 closed 1 month ago

bjh45964 commented 1 month ago

Trying to add SegoeUI font for new badge, get an "Attachment is invalid" error when loading. It looks like badger checks to make sure the MIME type is one of:

'image/jpeg', 'image/png', 'application/x-font-ttf', 'application/x-font-truetype'

I added 'application/x-font-ttf', 'application/x-font-truetype' mappings to ttf in /etc/mime.types, restarted apache, no change. I'm not sure if this mime type needs to be set somewhere else, or if something else is going on.

slmclane commented 1 month ago

The attachment controls seem to use paperclip, which is deprecated and replaced with built-in ActiveRecord attachment functionality. However, paperclip methods are extended in the paperclip_processors folder. Paperclip was forked into KT-Paperclip which may be able to handle the custom code.

[paperclip] Trying to link /tmp/RackMultipart20240526-12808-1691jnq.ttf to /tmp/e8e4fb0d0cace261e00c1888dacbd31320240526-12808-36uc7n.ttf [paperclip] Trying to link /tmp/e8e4fb0d0cace261e00c1888dacbd31320240526-12808-36uc7n.ttf to /tmp/e8e4fb0d0cace261e00c1888dacbd31320240526-12808-11qmf7.ttf Command :: file -b --mime '/tmp/e8e4fb0d0cace261e00c1888dacbd31320240526-12808-11qmf7.ttf'

slmclane commented 1 month ago

Successfully got the attachment control to accept .ttf files by adding the content type 'font/ttf' to the validation step in artifact.rb:

  validates_attachment :attachment, content_type: {
    content_type: ['image/jpeg', 'image/png', 'application/x-font-ttf', 'application/x-font-truetype','font/ttf']
  }