Skip to content
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

feat(upload): add option to define desired mime types #330

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jdrzejb
Copy link

@jdrzejb jdrzejb commented May 23, 2022

Hi,

I found this option missing, so decided to create a feature branch for it. Let me know if this can be merged.

@LiamKarlMitchell
Copy link

LiamKarlMitchell commented Oct 30, 2022

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)
            }
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants