angularfile-uploaduploadcare

Uploadcare widget with multi-file uploads limited with max size


I have an Uploadcare widget with multi-file uploads.

<ngx-uploadcare-widget #uploadCare 
  images-only="true"
  multiple="isMultiple"
  multiple-min="0"
  multiple-max="10
  data-max-size="21048576"
  data-clearable="true" 
  public-key="****"
  (on-change)="onFileUploadChange($event)">
  1. I want the uploaded files size to not exceed 2 MB. How do I set max-size for the all uploaded files?

  2. How can I prevent duplication for uploading files?


Solution

    1. There's no such an option out of the box, but you can achieve this with file validation. Check out an example in the demo app here. A validation function has access to file information before it's completely uploaded and allows you to validate the file size, name, mime-type, image dimensions, etc. If the file doesn't pass the validation, you can abort uploading and throw a custom error.

    2. Checking for file duplicated is not supported by Uploadcare.