You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to reject IFC files but allow 3DM and SKP files. To accomplish this I used the SpatieMediaLibraryFileUpload component in my Resource form and wanted to use the ->acceptedFileTypes() function. I checked the source code and it sets rules for the mime types, so I researched which mime types where detected by PHP for these files:
The SKP file is correctly detected but the IFC and 3DM files are empty strings. From this observation you would expect the SKP file to be correctly validated but this is not the case (see first image). However when I add 'application/vnd.koan' :
I'm trying to wrap my head around on what is happening, but I suspect the problem is that there is a different mechanism for mime detection. Since you use FilePond under the hood, this might do a different mime detection.
In any case do you have any suggestions on how to solve this problem?
I do think that the fix is unlikely to be in Filament your best bet is trying to reproduce the problem with Filepond and Livewire and pull request there. None of the file upload logic in Filament is really custom
Package
filament/spatie-laravel-media-library-plugin
Package Version
v3.2.140
Laravel Version
v11.42.1
Livewire Version
v3.5.20
PHP Version
PHP 8.3.16
Problem description
I want to reject IFC files but allow 3DM and SKP files. To accomplish this I used the
SpatieMediaLibraryFileUpload
component in myResource
form and wanted to use the->acceptedFileTypes()
function. I checked the source code and it sets rules for the mime types, so I researched which mime types where detected by PHP for these files:So I added the ones I want to allow to the component:
What happens after uploading all three files is that they all fail in their validation:
So I decided to check which mime types are detected:
This leads me to the following discovery:
The SKP file is correctly detected but the IFC and 3DM files are empty strings. From this observation you would expect the SKP file to be correctly validated but this is not the case (see first image). However when I add
'application/vnd.koan'
:The SKP file is correctly uploaded:
I'm trying to wrap my head around on what is happening, but I suspect the problem is that there is a different mechanism for mime detection. Since you use FilePond under the hood, this might do a different mime detection.
In any case do you have any suggestions on how to solve this problem?
Expected behavior
When I build the component like this:
Or ideally using the actual mime type for 3DM files
'model/x-3dmf'
instead of'application/octet-stream'
.I want to be able to upload 3DM and SKP files, rejecting IFC files.
Steps to reproduce
Create a
Resource
and add aSpatieMediaLibraryFileUpload
component to the form schema:Then try to upload a SKP, IFC and 3DM file. You will see that they will all be rejected.
Unfortunately I cannot upload these files here so I created a WeTransfer link that is valid for 7 days: Link to download these files
Reproduction repository (issue will be closed if this is not valid)
https://github.com/fmeccanici/filament-replicate-file-upload-problem
Relevant log output
The return of
->getMimeType()
for these files inside->afterStateUpdated
:The text was updated successfully, but these errors were encountered: