mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
fix file upload bug (#1928)
- proper extraction of File objects from the FileList
This commit is contained in:
committed by
Eugenio Romano
parent
0c995bff6e
commit
3b3b8b4fa8
@@ -128,7 +128,7 @@ export class UploadButtonComponent implements OnInit, OnChanges {
|
||||
* @param {File[]} files - files dropped in the drag area.
|
||||
*/
|
||||
onFilesAdded($event: any): void {
|
||||
let files = $event.currentTarget.files;
|
||||
let files: File[] = this.getFiles($event.currentTarget.files);
|
||||
|
||||
if (this.hasPermission) {
|
||||
this.uploadFiles(this.currentFolderPath, files);
|
||||
@@ -145,7 +145,7 @@ export class UploadButtonComponent implements OnInit, OnChanges {
|
||||
* @param {File[]} files - files of a folder dropped in the drag area.
|
||||
*/
|
||||
onDirectoryAdded($event: any): void {
|
||||
let files = $event.currentTarget.files;
|
||||
let files: File[] = this.getFiles($event.currentTarget.files);
|
||||
if (this.hasPermission) {
|
||||
let hashMapDir = this.convertIntoHashMap(files);
|
||||
|
||||
@@ -211,6 +211,18 @@ export class UploadButtonComponent implements OnInit, OnChanges {
|
||||
return directoryMap;
|
||||
}
|
||||
|
||||
private getFiles(fileList: FileList): File[] {
|
||||
const result: File[] = [];
|
||||
|
||||
if (fileList && fileList.length > 0) {
|
||||
for (let i = 0; i < fileList.length; i++) {
|
||||
result.push(fileList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split the directory path given as input and cut the last directory name
|
||||
* @param directory
|
||||
|
Reference in New Issue
Block a user