Upload Widget preBatch error
When calling the cloudinary.openUploadWidget() function I am trying to do some preBatch processing by including the preBatch parameter.
preBatch: (cb, data) => {
console.log(data)
cb()
}
The console.log command works and gives me a list of the selected files but when the browser tries to execute the cb() command I get this error: uncaught TypeError: Cannot read property 'type' of undefined
at Object.O.b.types.n.(widget.cloudinary.com/v2.0/n/......./149/anonymous function) [as uw_prebatch]
Am I using the preBatch parameter in a wrong way?
-
Official comment
Hi Michalis,
As an update - the widget has been updated and it now should work as originally documented, without the empty object in the callback as a workaround.
Can you please let me know if you're still seeing issues?
Regards,
Stephen -
Hi Michalis,
Thanks for bringing this to my attention; it appears there's a mistake in the example in the documentation. I'll ask the documentation team to look into that.
The problem with your code is that cb() function can't be called with no parameters.
For the case where you want to allow the upload to proceed without canceling it, you must pass an empty object as a parameter, e.g. cb('{}');
For example, this should work:preBatch: (cb, data) => {
console.log(data);
cb({});
}Please give it a try and let me know if that solves your issue
0
Post is closed for comments.
Comments
2 comments