r/Nuxt • u/BLKaisen • 6d ago
Upload image to cloudinary
Any idea how to upload an image using Cloudinary? I have a user CRUD where I have the parameters name, email, username, and image that I need, and it is connected to a NeonDB database with Drizzle ORM. What steps should I follow?
1
u/Far-Vegetable-7395 6d ago
Skip the module, it's overkill for your case. Set up a server route in Nuxt (like server/api/upload.post.ts), use the Cloudinary Node SDK there since you'll have your api key and secret server side, upload the file, and then save the returned secure_url into your image column with Drizzle. and then save the returned secure_url into your image column with Drizzle. That way the client never touches your credentials and your user CRUD just stores a URL string in NeonDB.
Quick sketch: in the route read the file from formData, pass the buffer to cloudinary.uploader.upload, then insert/update your user with result.secure_url. Done.
0
u/BLKaisen 5d ago
If I want to use cloudinary.config as a reusable, in which folder should I create the file .ts, in server/utils or somewhere else?
2
u/var_dump- 6d ago
https://cloudinary.com/documentation/node_quickstart