keystone-classic
keystone-classic copied to clipboard
Cloudinary: multiple images upload not working
In some reason, upload of multiple files to Cloudinary not working, if I'm trying to upload more than two files. Just one (random) picture being uploaded.
The model is very simple:
const keystone = require('keystone');
const Types = keystone.Field.Types;
const Gallery = new keystone.List('Gallery', {
autokey: { from: 'name', path: 'key', unique: true },
});
Gallery.add({
name: { type: String, required: true },
publishedDate: { type: Date, default: Date.now },
image: { type: Types.CloudinaryImages, autoCleanup : true }
});
Gallery.register();
Each image i'm trying to upload is not bigger than ~500KB
Thanks
same by me. only one image uploaded.
The problem is also by the keystone Demo: http://demo.keystonejs.com/keystone/galleries if you upload many images, only one of them will be safed. I tried it with: Firefox, Chrome on Mac and Windows!
@asaptf and @milanffm, have you tried this with the latest version of Keystone?
yeah with 4.0.
I face this issue too.
This worked in a previous version and I find it not working anymore. One application in production is still running 4.0.0-rc.0 which it doesn't work in and moving to 4.1.1 it remains broken. We moved to 4.0.0-rc.0 some time ago because it resolved some issues, unaware of breaking this feature. Edit: Actually, double checking it does work when I set Keystone version to 4.0.0-rc.0 and rc.1 but not 4.0.0 or higher.
Issues hasn't been fixed yet. Version 4.1.1
this only works in version: 4.0.0-beta.8
Does anybody know how to fix this issue? Unfortunately downgrade will cause another issues, which have been fixed already 😅
this only works in version: 4.0.0-beta.8
Have you tried rc.0 and rc.1? I rolled back some versions and then forward again. And it started working so it might be something to do with an npm dependency, perhaps with a non-specific version. I'm not sure how to debug it without it upgrading all the packages down the line automatically.
Edit: I've just realised it works with 1 or 2 images but any more and it only uploads 1.
Hi guys,
Had a look in the type definition file : CloudinaryImagesType. Looks like the _.flatten() function isn't working well and the array given to the async.map (which will upload the files to cloudinary) isn't really flattened (Only on depth level one)
The workaround was to write a flattening function instead of using the lodash one (which works only on one depth level).
Here the function in the file 'keystone\fields\types\cloudinaryimages\CloudinaryImagesType.js' :
const flatten = arr => arr.reduce( (a, b) => a.concat(Array.isArray(b) ? flatten(b) : b), [] ); values = flatten(values)
Instead of :
values = _.flatten(values);
@Niiitzer thanks a lot, mate! This works awesome!
@Niiitzer thanks man, that was the fix for this :-) yeah
Did someone make a PR for this?
Did someone make a PR for this?
There's currently a monolithic PR ( https://github.com/keystonejs/keystone/pull/4774 ) that has been looming around for some time that likely addresses this too. It's too big to merge as one PR so it's waiting for someone to split it up into multiple PR so changes and issues can be tracked better. Currently keystone is "stable" even though sometimes buggy it doesn't break so keeping PRs manageable is a priority.
Thanks! @Niiitzer I got it working finally!