Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check the file type being uploaded before performing upload #2584

Merged
merged 12 commits into from
Jul 27, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -1160,10 +1160,12 @@ export class MgtFileUpload extends MgtBaseComponent {
let entry: FileSystemEntry;
const collectFilesItems: File[] = [];

for (const uploadFileItem of filesItems as DataTransferItemList) {
if (uploadFileItem.kind === 'file') {
// Defensive code to validate if function exists in Browser
// Collect all Folders into Array
for (let uploadFileItem of filesItems) {
const dataTransferItemType = uploadFileItem instanceof DataTransferItem;
const fileType = uploadFileItem instanceof File;

if (dataTransferItemType) {
uploadFileItem = uploadFileItem as DataTransferItem;
const futureUpload = uploadFileItem as FutureDataTransferItem;
if (futureUpload.getAsEntry) {
entry = futureUpload.getAsEntry();
Expand Down Expand Up @@ -1195,14 +1197,17 @@ export class MgtFileUpload extends MgtBaseComponent {
}
}
continue;
} else {
const fileItem = uploadFileItem.getAsFile();
if (fileItem) {
this.writeFilePath(fileItem, '');
collectFilesItems.push(fileItem);
}

if (fileType) {
uploadFileItem = uploadFileItem as File;
Mnickii marked this conversation as resolved.
Show resolved Hide resolved
if (uploadFileItem) {
this.writeFilePath(uploadFileItem, '');
collectFilesItems.push(uploadFileItem);
}
}
}

// Collect Files from folder
if (folders.length > 0) {
const folderFiles = await this.getFolderFiles(folders);
Expand Down
Loading