keystone-classic: 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

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 9
  • Comments: 16 (4 by maintainers)

Most upvoted comments

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);

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.

Issues hasn’t been fixed yet. Version 4.1.1

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.