FileUploadItem is added

This commit is contained in:
병준 박 2019-11-05 13:40:01 +09:00
parent a4ee7cc83e
commit 8da169a144
2 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,38 @@
import { Observable, Subject } from 'rxjs';
import { share } from 'rxjs/operators';
export class FileUploadItem {
file: File;
uploadTime: number;
uploadingProgress$: Observable<number>;
private uploadingProgress: Subject<number>;
private uploadStartTime: number;
private constructor(file: File) {
this.file = file;
}
static fromFiles(files: File[]): FileUploadItem[] {
const fileItems: FileUploadItem[] = [];
for (const file of files) {
fileItems.push(new FileUploadItem(file));
}
return fileItems;
}
uploadStart(): Subject<number> {
this.uploadStartTime = new Date().getTime();
this.uploadingProgress = new Subject<number>();
this.uploadingProgress$ = this.uploadingProgress
.asObservable()
.pipe(share());
return this.uploadingProgress;
}
uploadComplete() {
const endTime = new Date().getTime();
this.uploadTime = endTime - this.uploadStartTime;
this.uploadingProgress.complete();
}
}

View File

@ -15,6 +15,8 @@ export * from './lib/apis/trans-mass-talk-save';
export * from './lib/apis/translation-req'; export * from './lib/apis/translation-req';
export * from './lib/apis/translation-save'; export * from './lib/apis/translation-save';
export * from './lib/models/file-upload-item';
export * from './lib/services/common-api.service'; export * from './lib/services/common-api.service';
export * from './lib/ucap-common-api.module'; export * from './lib/ucap-common-api.module';