Unable to upload multiple images to cloudinary
I'm trying to upload multiple images to cloudinary:
const cloudinary = require('cloudinary');
const path = require('path');
const imagePath = path.join(__dirname,'/test','/*.png');
cloudinary.config({
cloud_name: '****',
api_key: '******',
api_secret: '*******'
})
cloudinary.uploader.upload(imagePath, function(result) {
console.log(result)
});
I got this error message:
{ error:
{ Error: ENOENT: no such file or directory, open '/home/user1/cloudinary/test/*.png'
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/home/user1/cloudinary/test/*.png' } }
The program works with a single image. How can I do to upload multiple images in the same time?
Hi, You can iterate through the list of images in a loop and upload the images one by one. cloudinary.uploader.upload() uploads one image at a time. For client side uploads we have a upload widget where you can upload multiple images. For more information:https://cloudinary.com/documentation/upload_widget#quick_example
So no way to upload it simultaneously ?
While our upload API currently only supports a single file upload at a time, it does have a high concurrency rate (of about 40-50 concurrent calls) so you can use multi-threads to upload many files at once.
You can also use asynchronous calls, and tell Cloudinary to do the upload in the background by adding the async parameter and setting it to true.
Closing this issue due to the time elapsed. Please feel free to either re-open the issue, contact our support at http://support.cloudinary.com or create a new ticket if you have any additional issues.
Im trying the way you said and it is not working, got the same message, error: [Error: ENOENT: no such file or directory,
code on backend: const express = require('express'), router = express.Router(), multerUploads = require('../middleware/multer.config'), cloudinary = require('cloudinary').v2, cloudinaryconfig = require('../middleware/cloudinary.config'), PublicacionModel = require('./publicaciones.model');
cloudinary.config({
cloud_name: cloudinaryconfig.cloud_name,
api_key: cloudinaryconfig.api_key,
api_secret: cloudinaryconfig.api_secret,
})
router.route('/registrar_publicacion') .post( multerUploads, (req, res) => {
console.log(req.body);
for(let i=0; i<req.body.length; i++){
let imagePath = req.body[i].path;
cloudinary.uploader.upload(imagePath)
.then( (res) => {
console.log(res);
})
.catch( (err) => {
console.log('error');
console.log(err);
})
}
on the backend I'm receiving the path of the images, like image.png, dont know how to get the full path like "myPC/documents/folder/image.png", maybe that the issue?
Hi @isaacSolano , I saw you opened the same issue on request 287, you are welcome to look at the answer there.
Thanks for answering, in this case the front end only provides me an object with the path property for each file, the req.body looks like this. req.body { image1: picture1.png image2: picture2.png }
on the front end I'm using dropzone , still it doesnt give me the full path of the file, on the front end I only have "picture.png" for the path property on the file object
Hi @isaacSolano,
If you want to upload from server side you will have to specify a full path (or any other data upload options). If dropzone or any other service you are using cant supply this data, I can suggest an alternative, to upload directly from your front-end, by using one of these options:
-
Cloudinary's Upload Widget for unsigned uploads without using server side. This is a complete, interactive user interface that enables to upload files from a variety of sources to your website or application. read more about it here.
-
Direct uploading from the browser, can be used for signed upload, through server-side. It is easy to integrate with your code. More info here.
Hi @michalkcloudinay Im using the unsigned upload preset now, i have this issue when using an unsigned upload_preset: error: Upload preset must be whitelisted for unsigned uploads when using unsigned presets, the code

Important: the upload preset i'm using is is unsigned already
"Upload preset must be whitelisted for unsigned uploads" is usually when you try and use signed preset instead of unsigned. Can you please open a support ticket here:https://support.cloudinary.com/hc/en-us/requests/new and share your cloud name and upload preset and I will be able to debug this further.
@aditimadan-Cloudinary Ticket submitted, thank you guys for your help and assistance. 👍
for those, who are using streams, here is quick and simple way of doing this: https://gist.github.com/sinnrrr/58901f7cdf77e299dc00ed23f362fcb8
Hello, You need to put "Overwrite" to "Off" in all others presets So you can use the preset you want