question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue uploading multiple cloudinary images via API (Angular SPA)

See original GitHub issue

Hello 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:closed
  • Created 9 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
mandymozartcommented, Mar 14, 2015

I never saw the multi images upload work in the Admin UI.

is there any info to why?

Thanks

0reactions
intrnetcommented, Jan 16, 2018

This is the answear:

<label>
	<span>Images</span>
	<input type="hidden" name="images" value="upload:Img">
        <input type="file" accept="image/*,application/pdf,application/postscript" multiple="" name="Img">
</label>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue uploading multiple cloudinary images in Keystone ...
I am working on a SPA application integrating Keystone.js with cloudinary-angular. The problem is that cloudinary-angular is NOT using direct-upload ...
Read more >
Upload more than one image · Issue #152 - GitHub
I'm uploading my images perfectly also using Angular 5 but I was wondering if would be possible to upload more than one image...
Read more >
How can I bulk upload my images? - Cloudinary Support
Hi, When uploading directly from the browser, you can set the 'multiple' attribute and allow drag & drop of multiple files. On the...
Read more >
Upload 1000 images? - Cloudinary Support
I have all the 1000 or so images locally on my hard drive. I need to upload each one, and write in my...
Read more >
Angular Image and Video Upload - Cloudinary
When using the Angular SDK, you can use one of several options to upload files directly to Cloudinary without the need for server-side ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found