-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pem-File causes "File extension does not match known MIME type" #47
Comments
A .pem file seems like the sort of thing that should not be uploaded via a webapp What's the use case here? |
The admin has to be able to upload a publickey for rsa-encryption... bank account credentials have to get encrypted before storing them to the database...
|
While not PEM file related, I am trying to upload a 3d model, glb and gltf files to the CMS for a project. I have added the following to my yaml config -
But when I go to upload the file in the CMS I get the following error -
If I look at the network request - I can see in the formdata that the file mime type is
Any ideas on how to actually allow SS to allow uploads of non standard files as this doesn't seem possible even when following the docs at - https://docs.silverstripe.org/en/5/developer_guides/files/allowed_file_types/ This is testing with SS5 |
Seems like it's failing in MimeUploadValidator::isValidMime() - I'd recommend you put a debug breakpoint in there to isolate what's causing the mime validation to fail |
So when testing, and hard breaking, the mime type for some reason returning as application/octet-stream I added that to the possible options and was able to upload it now. But my main question is why would SS see the file as that mime type when the posted upload clearly has the mime type set as model/gltf+json. Not sure if this is a webserver issue, SS issue or even OS issue. This was debugged on apache/php 8.2/mac OS If I had to guess the original bug submitter was running into a similar issue where even though the proper mime type was posted and configured, it was being read as something else. |
Not sure. The mimevalidator uses the PHP Fileinfo extension:
Was that what finfo() was returning? Or was finfo() returning application/octet-stream? |
So the web browser POST request was showing the proper mime type posted of model/gltf+json. When outputting the value of the $foundMime variable from line 68 - https://github.com/silverstripe/silverstripe-mimevalidator/blob/3/src/MimeUploadValidator.php#L68 it was marked as application/octet-stream Trying to research this, it looks like it simply uses the mime types configured via your server/webserver so in this case what Apache would return in my instance. If I add the following to my Apache config though -
the fileinfo is still returning application/octet-stream. Since this is a core php function clearly not a SS issue but if you have any ideas on this is greatly appreciated. |
Hi I added pem in the setAllowedExtensions and added the mime type to the mimevalidator
SilverStripe\MimeValidator\MimeUploadValidator: MimeTypes: pem: - 'application/x-pem-file'
still getting "the unkown mimetype error"
The text was updated successfully, but these errors were encountered: