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.
|
* @param {File[]} files - files dropped in the drag area.
|
||||||
*/
|
*/
|
||||||
onFilesAdded($event: any): void {
|
onFilesAdded($event: any): void {
|
||||||
let files = $event.currentTarget.files;
|
let files: File[] = this.getFiles($event.currentTarget.files);
|
||||||
|
|
||||||
if (this.hasPermission) {
|
if (this.hasPermission) {
|
||||||
this.uploadFiles(this.currentFolderPath, files);
|
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.
|
* @param {File[]} files - files of a folder dropped in the drag area.
|
||||||
*/
|
*/
|
||||||
onDirectoryAdded($event: any): void {
|
onDirectoryAdded($event: any): void {
|
||||||
let files = $event.currentTarget.files;
|
let files: File[] = this.getFiles($event.currentTarget.files);
|
||||||
if (this.hasPermission) {
|
if (this.hasPermission) {
|
||||||
let hashMapDir = this.convertIntoHashMap(files);
|
let hashMapDir = this.convertIntoHashMap(files);
|
||||||
|
|
||||||
@@ -211,6 +211,18 @@ export class UploadButtonComponent implements OnInit, OnChanges {
|
|||||||
return directoryMap;
|
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
|
* Split the directory path given as input and cut the last directory name
|
||||||
* @param directory
|
* @param directory
|
||||||
|
Reference in New Issue
Block a user