DevExpress/devextreme-angular

Validate file size in the dx-file-uploader.

sabbirbiam opened this issue · 1 comments

Hi, I am trying to upload multimedia. But I have a requirement that video files are not more than 200MB and audio files not more than 15 MB and others files not more than 20 MB. To check this I have taken the event onBeforeSend. But I can not able to stop uploading if it does not meet the validation. My requirement is, I would like to check the multimedia size based on the multimedia type. If the specific multimedia does not meet the validation then I would like to cancel that request by throwing messages like "File size less than 100 MB.

My code is:

onBeforeSend(e): void { 
    if (e.file.type === 'image/png') {
      if (e.file.size >= 1000) {
        const testt = this.fileUploaderComponent;
        const testtss = this.fileUploaderComponent?.instance;
        this.fileUploaderComponent?.instance?.abortUpload?.();
        this.fileUploaderComponent?.abortUpload?.();
        const test = e?.instance?.();
        test?.abortUpload?.();
        e?.component?.abortUpload?.();
        e.abortUpload?.();
        e.request?.abortUpload?.();
        e.request?.abort?.();
      }
    }
  }

Hi,

Could you please submit a ticket to our support center and attach a demo project to demonstrate the issue?