1- import { UppyFileData , UppyUploaderService } from './uppy-uploader.service' ;
1+ import { UppyFileData , UppyUploaderService , ALLOWED_FILE_TYPES } from './uppy-uploader.service' ;
22import { environment } from '@v3/environments/environment' ;
33import { NotificationsService } from './../../services/notifications.service' ;
44import { Component , OnInit , Input , Output , EventEmitter , OnDestroy } from '@angular/core' ;
55import { Uppy , UppyFile , UppyOptions , } from '@uppy/core' ;
66import { ModalController } from '@ionic/angular' ;
77import { BrowserStorageService } from '../../services/storage.service' ;
8- import { UtilsService } from '../../services/utils.service' ;
98
109type FileMetadata = { [ key : string ] : any } ;
1110type FileBody = { [ key : string ] : any } ;
@@ -18,13 +17,6 @@ type FileBody = { [key: string]: any };
1817export class UppyUploaderComponent implements OnInit , OnDestroy {
1918 @Input ( ) source ! : "chat" | "profile" | "assessment" | "any" | "video" | "document" | "image" ;
2019 @Input ( ) tusEndpoint ?: string = environment . uppyConfig . tusUrl ; // tusUrl
21- @Input ( ) allowedFileTypes : string [ ] = [
22- "image/*" ,
23- "video/*" ,
24- ".jpeg" ,
25- ".png" ,
26- "application/pdf" ,
27- ] ;
2820 @Output ( ) uploadComplete = new EventEmitter < any > ( ) ;
2921
3022 uploadedFile : UppyFile < any , any > | null = null ;
@@ -44,7 +36,6 @@ export class UppyUploaderComponent implements OnInit, OnDestroy {
4436 private modalController : ModalController ,
4537 private storageService : BrowserStorageService ,
4638 private uppyUploaderService : UppyUploaderService ,
47- private utils : UtilsService ,
4839 ) {
4940 this . uppyProps . height = '500px' ;
5041 this . uppyProps . note = "Upload a file here" ;
@@ -59,13 +50,11 @@ export class UppyUploaderComponent implements OnInit, OnDestroy {
5950 throw new Error ( "source is required." ) ;
6051 }
6152
62- this . allowedFileTypes = this . loadAllowedFileTypes ( ) ;
63-
6453 this . uppy = this . uppyUploaderService . createUppyInstance ( this . source , this . tusEndpoint , {
6554 onAfterResponse : this . onAfterResponse . bind ( this ) ,
6655 onUploadSuccess : this . onUploadSuccess . bind ( this ) ,
6756 } , {
68- allowedFileTypes : this . allowedFileTypes ,
57+ allowedFileTypes : this . loadAllowedFileTypes ( ) ,
6958 } ) ;
7059 }
7160
@@ -85,11 +74,7 @@ export class UppyUploaderComponent implements OnInit, OnDestroy {
8574 case "chat" :
8675 case "any" :
8776 default :
88- return [
89- "image/*" ,
90- "video/*" ,
91- "application/*"
92- ] ;
77+ return ALLOWED_FILE_TYPES ;
9378 }
9479 }
9580
0 commit comments