fix file upload bug (#1928)

- proper extraction of File objects from the FileList
This commit is contained in:
Denys Vuika
2017-06-02 22:08:21 +01:00
committed by Eugenio Romano
parent 0c995bff6e
commit 3b3b8b4fa8

View File

@@ -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