Issue uploading multiple cloudinary images via API (Angular SPA)
See original GitHub issueHello friends,
I am working on a SPA application integrating Keystone.js with cloudinary-angular. The problem is that cloudinary-angular is NOT using direct-upload technique, so keystone is ignoring images despite the fact that I am sending JSON data in exact same format that keystone expects (tried this after sending as is didn’t work).
This is a non-issue when uploading single image (heroImage), not sure why it works for single image (type: cloudinaryImage) but not multiple images (type: cloudinaryImages).
Is there any workaround/way to fix this issue? Any hints on how can I use direct-upload (or whatever keystone likes) in API/SPA scenario?
Here is the code on git: https://github.com/sgireddy/KeystoneAngularSPA
Looks like this is what I am hitting in cloudinaryimages.js:
/**
* Updates the value for this field in the item from a data object
*
* @api public
*/
cloudinaryimages.prototype.updateItem = function(item, data) {
// TODO - direct updating of data (not via upload)
};
I tried messing around with cloudinaryimages.prototype.getRequestHandler and found that corresponding admin UI code here:
// Upload References (direct uploading)
if (req.body[paths.uploads]) {
var uploads = JSON.parse(req.body[paths.uploads]);
uploads.forEach(function(file) {
item.get(field.path).push(file);
});
}
whatever req.body[paths.uploads] is actually req.body.images in my code, so I added the following code after above section:
if (req.body.images_upload) {
var uploads = req.body.images_upload;
uploads.forEach(function (file) {
item.get(field.path).push(file);
});
}
This time I got a new issue:
{ [CastError: Cast to ObjectId failed for value "{"public_id":"preset_folder/kgs ****** at path "_id"',
Looks like I need to generate mogodb _id for each image, being a node novice I have no idea how to do that either… but all this is a big hack anyways…
can somebody help, please…
Thanks, shashi
Issue Analytics
- State:
- Created 9 years ago
- Comments:6 (1 by maintainers)
Top GitHub Comments
I never saw the multi images upload work in the Admin UI.
is there any info to why?
Thanks
This is the answear: