13 Replies
I am currently implementing the Cloduinary API to upload images (thats the only purpose), to add multiple images, i am simply iterating over all the images, and adding them one by one, then returning the url and finally adding it to a database
So i was wondering if a method similar to .AddRange exists for this API
How would you handle multiple image uploads with the cloduinary API?
Cloudinary primarily provides methods to upload images one by one, and there isn't a built-in .AddRange-like method to upload multiple images in a single request using the Cloudinary API. To handle multiple image uploads efficiently, you would typically iterate through your list of images and upload them individually. However, you can optimize the process to make it more efficient and convenient.
Thank you so much for the response. Will be looking for ways to make it more optimal, because sometimes it feels kinda slow, however that will always be tied to upload speed.
No prob, You can drop the code and we I can help optimize it as well
This is what I currently have, this is in charge of uploading an image only. One by one
To add images, I do a foreach and add them one by one.
The new images are saved in the image table, with a foreign key reference to the items table, for easy retrieval with nav properties
When we add the post, we first save the post into the db, save the changes and send the image collection to the AddImages method
The dto its necessary to avoid a json serialization error I got
So there are a total of three o(n) complexity operations there.
* the foreach for every image upload
* the .Select for mapping the image to an imageDto
* and the .AddRange of the imageDto collection that I return
And this is the controller btw, no iterations done here since its just one entity
Well with this I removed one iteration @softmek
Or, maybe no, there is still and AddRange and a Select
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.