F
Filament9mo ago
GDG

Uploading font files .ttf and .otf

Has anybody been able to upload .ttf or .otf font files using FileUpload? I have even tried the following ->acceptedFileTypes(['application/x-font-ttf', 'font/ttf', '.ttf']) but I constantly get "File of Invalid Type". Not doing anything crazy with the component and images etc work just fine. Forms\Components\FileUpload::make('header_font_file')->directory('fonts')->visibility('public')->acceptedFileTypes(['application/x-font-ttf', 'font/ttf', '.ttf'])
28 Replies
GDG
GDGOP9mo ago
I should note that if I do not set any acceptedFileTypes that the file looks like it passes with FileUpload but it doesn't go into temporary storage and when I save the resource, it doesn't get saved to main directory either.
awcodes
awcodes9mo ago
Run your file through an actual mimetype check to make sure it is one of those file types.
GDG
GDGOP9mo ago
Hey @awcodes, I checked this to be application/x-font-ttf but I have tried with many other files of the same type too. it is also the same with .otf Nobody else experienced this at all? I’m going to assume it’s a Filament bug and report it 👍
awcodes
awcodes9mo ago
As long as the mine type is correct I don’t see why filepond or filament would care. Honestly not sure what the problem would be.
GDG
GDGOP9mo ago
It is a strange one for sure. I don't have issues with any other file type except fonts.
awcodes
awcodes9mo ago
Are you getting a validation error or a server error?
GDG
GDGOP9mo ago
Nope. It immediately errors out as File of Invalid Type in FileUpload and then if I remove all acceptedFileTypes it allows (appears to) the upload but nothing gets added to temporary and upon save, the FileUpload is empty, nothing gets passed to the database and nothing gets uploaded. Everything is standard. Forms\Components\FileUpload::make('header_font_file')->directory('fonts')->visibility('public')->acceptedFileTypes(['application/x-font-ttf', 'font/ttf', '.ttf']) If I change the filetype to anything else, it all just works
awcodes
awcodes9mo ago
Can you try removing the .ttf since that isn’t an actual mime type?
GDG
GDGOP9mo ago
I have tried all combinations of them individually and all together but I will try this again now.
awcodes
awcodes9mo ago
Also can you send a screenshot of the error. That might help me to understand where the issue is occurring.
GDG
GDGOP9mo ago
Sure, here you go
No description
GDG
GDGOP9mo ago
Here is one with just the ttf mime types
No description
awcodes
awcodes9mo ago
The file types are being passed directly to filepond, so could be a bug in fileponds file type plugin. I’m wondering too if your server doesn’t recognize the mine type. And therefore can’t properly determine it from the tmp uploaded file.
GDG
GDGOP9mo ago
Well, this is local right now running on Herd. I could deploy tomorrow to my actual server and test there but not sure that that will make a difference in all honesty. Did you attempt to replicate the error? Not expecting you to try btw, I appreciate all of your help so far but was just wondering if you had tried on your side.
awcodes
awcodes9mo ago
Hmm, I would think heard would be ok. I haven’t tried. Busy with work and always from the computer right now.
GDG
GDGOP9mo ago
Yep, me too. I think it's just a bug, honestly but you're probably right that it is on Filepond side and not Filament.
awcodes
awcodes9mo ago
Not seeing any issues on fileponds GitHub about it.
GDG
GDGOP9mo ago
Honestly, just rubber ducking is a big help mate. Don't expect you to try.
awcodes
awcodes9mo ago
Could be something in livewire too and it’s TemporaryUploadedFile class.
GDG
GDGOP9mo ago
Thinking of accepting a .zip instead and unzipping locally 😂
awcodes
awcodes9mo ago
The fact that it’s not detecting it as an octet-stream is odd too.
GDG
GDGOP9mo ago
Yep, as the main fallback, I would have assumed that it would have taken that
awcodes
awcodes9mo ago
Zip would work, but you’d have to manage possible multiple files in it.
GDG
GDGOP9mo ago
Yeah, it's a closed system so I "could" tell the users to do so but users do user things...
awcodes
awcodes9mo ago
Not the end of the world. Might even be a benefit since they could upload ttf, woff, etc all in one go. Yes they do. 😅😂
GDG
GDGOP9mo ago
Thanks for all of your help mate. Appreciate what you do for us all as a community too. Back to the drawing board for now...
awcodes
awcodes9mo ago
Keep me in the loop. I’ll try it when I get a free moment, just for a sanity check and let you know.
GDG
GDGOP9mo ago
Appreciate you x

Did you find this page helpful?