-
Notifications
You must be signed in to change notification settings - Fork 20
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
"Unknown Mimetype" exception thrown #23
Comments
The issue is the API doesn't actually return a value for ContentType which is used in code to determine the FileAttribute's MimeType through the normalizeObject method. A few potential options are reading the raw file and creating a mime type for it or just guessing one based on the file extension. I'd be happy to do a PR for this ** Edit ** ** Edit 2 ** https://symfony.com/doc/current/components/mime.html ** Edit 3 ** |
Adding on to the prior comment what appears to work would be something like:
The standard implementation would look like the below, but there's an issue with large file sizes as it has to download the whole file to function.
Below is a tweaked version to handle larger file sizes. The 80 byte number comes from https://en.wikipedia.org/wiki/List_of_file_signatures listed in https://stackoverflow.com/questions/8673407/how-many-bytes-are-required-for-accurate-mime-type-detection. 80 bytes was longer than anything listed although it's not an exhaustive list. The stream needs the byte length limiter as otherwise it will read the whole stream (and be the same as read).
The final option would be something like the below that puts preference towards detection via file name in order to avoid downloading or streaming the file. The default behavior of the function detectMimeType does the opposite. It tries to read the file (or stream) and then use the extension as a fallback. Detecting via file reading should be more accurate while this version is quicker/doesn't use extra API calls where not needed.
|
@stevenmond works great, can you provide a PR? |
This should now be working now, massive thanks to @stevenmond 👏🏻. I wasn't happy with the 2× HTTP calls (1× for directory listing and 1× for contents) but I've test that it only occurs when the user asks for the The only two other notes are:
I'll reach out to Bunny and see if there's an ETA on first party mimeType support |
Closing with the release of https://github.com/PlatformCommunity/flysystem-bunnycdn/releases/tag/v3.1.2 |
After successfully using the package in a Laravel 8 project, I wanted to check it out with Laravel 9 and Statamic 3.3. I created the filesystem and also followed the Laravel 9 instructions.
When connecting the filesystem to Statamic, I get the following exception:
I can upload files (they appear in the bunny.net File Manager) but are not shown in Statamic, instead, the mentioned exception is thrown.
The text was updated successfully, but these errors were encountered: