@@ -22,9 +22,9 @@ import { FileData } from "./interfaces/file.interface";
2222import { FilesService } from "./services/files.services" ;
2323import { NgChanges } from "../typings/ng-onchange" ;
2424import { FileInputProperties , Space , Spacing } from "./dxc-file-input.types" ;
25- import { FileMetaData } from './model/filemetadata ' ;
26- import { chunkmetadata } from './model/chunkmetadata ' ;
27- import { IFileUploadRequest , EventType } from "./model/fileuploadrequestdata " ;
25+ import { FileMetaData } from './model/file.metadata ' ;
26+ import { ChunkMetaData } from './model/chunk.metadata ' ;
27+ import { IFileUploadRequest , EventType } from "./model/fileuploadrequest.data " ;
2828
2929@Component ( {
3030 selector : "dxc-file-input" ,
@@ -174,14 +174,13 @@ export class DxcFileInputComponent implements OnChanges, OnInit {
174174 hasSingleFile : boolean = false ;
175175 hasErrorSingleFile : boolean = false ;
176176 hasValue : boolean = false ;
177- globalFileHit : number = 0 ;
178177 globalChunkCount : number = 0 ;
179178 globalActualChunkCount : number = 0 ;
180179 fileDataUpload : FileMetaData ;
181180 GUID : string ;
182181 fileEventType : EventType = EventType . PREUPLOAD ;
183182 chunkResult : boolean ;
184- data : any ;
183+ data : Array < FileData > = [ ] ;
185184 postResp : any ;
186185
187186 constructor ( private utils : CssUtils , private service : FilesService ) {
@@ -192,7 +191,6 @@ export class DxcFileInputComponent implements OnChanges, OnInit {
192191 this . hasMultipleFiles = this . isMultipleFilesPrintables ( ) ;
193192 this . hasSingleFile = this . isSingleFilesPrintables ( ) ;
194193 this . callbackFile . emit ( files ) ;
195- this . uploadEventType . emit ( this . fileEventType ) ;
196194 }
197195 } ) ;
198196 }
@@ -344,18 +342,18 @@ uploadChunkDoc(file) {
344342 {
345343 setTimeout ( ( ) => {
346344 this . uploadcomplete ( this . fileDataUpload ) . then ( resp => {
347- this . data [ 0 ] . postresponse = resp ;
345+ this . data [ 0 ] . postResponse = resp ;
348346 this . fileEventType = EventType . POSTUPLOAD ;
349347 //let data = this.getPreview(file);
350- this . data [ 0 ] . eventtype = this . fileEventType ;
348+ this . data [ 0 ] . eventType = this . fileEventType ;
351349 this . callbackFile . emit ( this . data ) ;
352350 } ) ;
353351 } , 3000 ) ;
354352 }
355353 }
356354
357355 readFile ( file , lastChunksize : number , callback ) {
358- let filedata = new chunkmetadata ( ) ;
356+ let filedata = new ChunkMetaData ( ) ;
359357 filedata . fileName = this . globalActualChunkCount + "-" + this . GUID + file . name ;
360358 filedata . fileSize = file . size ;
361359 filedata . fileType = file . type ;
@@ -375,9 +373,9 @@ uploadChunkDoc(file) {
375373 return callback ( filedata , file , lastChunksize , false ) ;
376374 }
377375 }
378- private async uploads ( theFile : chunkmetadata )
376+ private async uploads ( theFile : ChunkMetaData )
379377 {
380- const response = await fetch ( this . requests . uploadrequest . url , {
378+ const response = await fetch ( this . requests . uploadRequest . url , {
381379 method : 'POST' ,
382380 body : JSON . stringify ( theFile ) ,
383381 headers : {
@@ -390,16 +388,9 @@ uploadChunkDoc(file) {
390388 if ( ! response . ok ) {
391389 throw new Error ( `Error! status: ${ response . status } ` ) ;
392390 }
393-
394- // const result: CreateUserResponse
395- // const result = (await response.json());
396-
397- // console.log('result is: ', JSON.stringify(result, null, 4));
398-
399- // return result;
400- }
391+ }
401392 private async uploadcomplete ( theFiles : FileMetaData ) {
402- const response = await fetch ( this . requests . uploadcompleterequest . url , {
393+ const response = await fetch ( this . requests . uploadCompleteRequest . url , {
403394 method : 'POST' ,
404395 body : JSON . stringify ( theFiles ) ,
405396 headers : {
@@ -445,17 +436,17 @@ uploadChunkDoc(file) {
445436 data : file ,
446437 image : null ,
447438 error : this . checkFileSize ( file ) ,
448- eventtype : this . fileEventType ,
449- postresponse : this . postResp
439+ eventType : this . fileEventType ,
440+ postResponse : this . postResp
450441 } ;
451442 this . service . addFile ( fileToAdd ) ;
452443 } else {
453444 let fileToAdd : FileData = {
454445 data : file ,
455446 image : event . target [ "result" ] ,
456447 error : this . checkFileSize ( file ) ,
457- eventtype : this . fileEventType ,
458- postresponse : this . postResp
448+ eventType : this . fileEventType ,
449+ postResponse : this . postResp
459450 } ;
460451 this . service . addFile ( fileToAdd ) ;
461452 }
0 commit comments