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

onBeforeUploadItem not working in versions >1.4 #1243

Open
elementalTIMING opened this issue Jan 11, 2023 · 1 comment
Open

onBeforeUploadItem not working in versions >1.4 #1243

elementalTIMING opened this issue Jan 11, 2023 · 1 comment

Comments

@elementalTIMING
Copy link

For a long time I was working with version 1.4. Now I've updated to v3.0.0. Unfortunately, onWhenAddingFileFailed is not called anymore. I also tried other versions > 1.4, but with the same result. I tried to upload files of a wrong file format and file with a too big file size and expected that onWhenAddingFileFailed is called, but no...

I'm wondering if I'm doing anything wrong or if there are any breaking changes (the documentation is a bit creepy)?

	const url = {
		url: myurl,
		additionalParameter: {
			directory: mydirectory,
			filename: myimage,
			allowOverride: false,
		},
		allowedFileType: ['image'],
		maxFileSize: 1 * 1024 * 1024,
	};

	this.uploader = new FileUploader(url);

	this.uploader.onWhenAddingFileFailed = (item, filter, options) => {
		console.log(item, filter, options);
	};

Does anybody has an idea or solution for my please?

@smileLilith
Copy link

smileLilith commented Jan 5, 2024

I have the same issue, the upgrade of ng2-file-upload from v1.4 to v2 and v3 caused a bunch of on* methods to stop working including onWhenAddingFileFailed.

The issue seems to be this line https://github.com/valor-software/ng2-file-upload/blob/21e04deafe36f96e617014056561c246bcc51759/libs/ng2-file-upload/file-upload/file-uploader.class.ts#L120C34-L120C34

If this._failFilterIndex is 0 then the statement isn't executed; 0 is a valid value for the array here. It should be changed to

        if (!!this._failFilterIndex) {

The issue seems to be fixed in v4+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants