fake image 쪽지쪽 처리.
This commit is contained in:
parent
f113e66377
commit
d6b518f29b
|
@ -178,26 +178,32 @@ export class WriteComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
return;
|
||||
}
|
||||
|
||||
for (let i = 0; i < fileList.length; i++) {
|
||||
const file = fileList.item(i);
|
||||
this.validUploadFile(fileList).then(async result => {
|
||||
if (!result) {
|
||||
return;
|
||||
} else {
|
||||
for (let i = 0; i < fileList.length; i++) {
|
||||
const file = fileList.item(i);
|
||||
|
||||
const dataUrl = await FileUtil.fromBlobToDataUrl(file);
|
||||
const img = document.createElement('img');
|
||||
img.src = dataUrl as string;
|
||||
img.setAttribute('style', 'max-height:250px; max-width:250px;');
|
||||
img[ATTR_FILE] = file;
|
||||
self.insertNode(img);
|
||||
const dataUrl = await FileUtil.fromBlobToDataUrl(file);
|
||||
const img = document.createElement('img');
|
||||
img.src = dataUrl as string;
|
||||
img.setAttribute('style', 'max-height:250px; max-width:250px;');
|
||||
img[ATTR_FILE] = file;
|
||||
self.insertNode(img);
|
||||
|
||||
const empty = document.createElement('div');
|
||||
empty.innerHTML = ' <br/>';
|
||||
self.insertNode(empty, true);
|
||||
}
|
||||
const empty = document.createElement('div');
|
||||
empty.innerHTML = ' <br/>';
|
||||
self.insertNode(empty, true);
|
||||
}
|
||||
|
||||
self.fileInput.nativeElement.value = '';
|
||||
self.fileInput.nativeElement.onchange = undefined;
|
||||
self.fileInput.nativeElement.value = '';
|
||||
self.fileInput.nativeElement.onchange = undefined;
|
||||
|
||||
self.checkContentLength();
|
||||
self.changeDetectorRef.detectChanges();
|
||||
self.checkContentLength();
|
||||
self.changeDetectorRef.detectChanges();
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -228,7 +234,7 @@ export class WriteComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
};
|
||||
}
|
||||
|
||||
validUploadFile(fileList: FileList): boolean {
|
||||
async validUploadFile(fileList: FileList): Promise<boolean> {
|
||||
let valid = true;
|
||||
if (this.fileAllowSize > 0) {
|
||||
for (let i = 0; i < fileList.length; i++) {
|
||||
|
@ -284,6 +290,39 @@ export class WriteComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||
return valid;
|
||||
}
|
||||
|
||||
const files: File[] = [];
|
||||
for (let i = 0; i < fileList.length; i++) {
|
||||
files.push(fileList.item(i));
|
||||
}
|
||||
const fakeMedia = await this.commonApiService.checkInvalidMediaMimeForFileTalk(
|
||||
files
|
||||
);
|
||||
if (!fakeMedia.accept) {
|
||||
this.ngZone.run(() => {
|
||||
this.snackBarService.openFromComponent<
|
||||
AlertSnackbarComponent,
|
||||
AlertSnackbarData
|
||||
>(AlertSnackbarComponent, {
|
||||
duration: 1000,
|
||||
verticalPosition: 'bottom',
|
||||
horizontalPosition: 'center',
|
||||
data: {
|
||||
html: this.translateService.instant(
|
||||
'common.file.errors.notAcceptableMime',
|
||||
{
|
||||
supporedType:
|
||||
fakeMedia.rejected.length > 0
|
||||
? fakeMedia.rejected.join(',')
|
||||
: ''
|
||||
}
|
||||
)
|
||||
}
|
||||
});
|
||||
});
|
||||
valid = false;
|
||||
return valid;
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user