danialfarid / ng-file-upload

Lightweight Angular directive to upload files with optional FileAPI shim for cross browser support
MIT License
7.87k stars 1.6k forks source link

Different max size validation for videos and images on the same element #2091

Open alok-agarwal opened 5 years ago

alok-agarwal commented 5 years ago

I want to allow uploading media for a gallery, which includes a mix of videos and images.

Before uploading, I am validating the files for max size using the ngf-max-size directive. Below is the code I have for the same,

<button class="btn"
               ngf-select="uploadFiles($files, $invalidFiles)"
               ngf-multiple="true"
               ngf-fix-orientation="true"
               ngf-accept="image/*,video/*"
               ngf-max-size="20MB"
               ngf-pattern=="'.jpg,.mp4'"
               ngf-max-files="10">Upload</button>

But I need to have different max sizes for videos and images for eg: images will have 10MB and videos will have 50MB, this does not seem possible with the ngf-max-size directive.

Is there a way this can be validated in the upload function? If we do not use the ngf-max-size, we will not have the invalidFiles. How will the error be triggered in that case?