advanced-nova-media-library
advanced-nova-media-library copied to clipboard
feat(upload): add option to define desired mime types
Hi,
I found this option missing, so decided to create a feature branch for it. Let me know if this can be merged.
There is a validation rule I am using already with laravel media library graphql. 'mimes:jpg,png,pdf' (or can specify full mime type values) https://laravel.com/docs/9.x/validation#rule-mimes
I wonder if the field can parse the rules and extract them if set.
When setting rules, and perhaps if enabled to do so by a config value? Parse rules and extract the mimetypes/file types allowed.
$rulesValidator = Validator::make([], [$requestAttribute => $this->collectionMediaRules]);
$mimesRule = $rulesValidator->getRule($this->attribute, 'mimes');
if (! is_null($mimesRule)) {
$parameters = $mimesRule[1];
if ($parameters) {
// May need to convert ?
$this->setAllowedMimeTypes($parameters);
$this->setAllowedFileTypes($parameters)
}
}