The issue you are facing is related to the validation rules for file uploads in the Spatie Laravel-medialibrary package. The error message suggests that the file type you are trying to upload is not allowed.
To resolve this issue, you need to update the validation rules to include the file types you want to allow. In your case, you want to allow files with the extensions ".stl" and ".constructioninfo".
Here's an example of how you can update the validation rules:
use Spatie\MediaLibrary\MediaCollections\Models\Media;
Media::addMediaValidationRules(function () {
return [
'file' => 'mimetypes:application/x-navistyle,application/vnd.ms-pki.stl,application/octet-stream,application/stl,application/sla,model/stl,model/x.stl-binary',
// Add more mimetypes if needed
];
});
Make sure to add this code in a suitable place, such as a service provider or a dedicated file for media library configuration.
This code adds a custom validation rule using the mimetypes rule provided by Laravel. It specifies the allowed mimetypes for the file upload. You can add more mimetypes if needed.
After updating the validation rules, you should be able to upload files with the extensions ".stl" and ".constructioninfo" without any issues.
Note: If you are using temporary uploads with S3, make sure to update the validation rules on the server-side as well.
Let me know if you have any further questions!