简体   繁体   中英

How do I retrieve an image url from Cloudinary using Node.js?

I uploaded images to cloudinary using cloudinary.uploader.upload(image, public_id:, function(error, result){console.log(result)}) Cloudinary then gives me the image url of the image that I uploaded.

Is there a way to retrieve an image url from Cloudinary using only my cloud name, api key and the public_id of the image?

To generate the Cloudinary URL directly via Node JS, you can use the cloudinary.url function. It accepts the following:

// cloudinary.url("<public_id>.<format>", {<transformations>})  
// Example
cloudinary.url("sample.jpg", {width: 100, height: 150, crop: "fill"})
// Output: "https://res.cloudinary.com/demo/image/upload/w_100,h_150,c_fill/sample.jpg"

Source: https://cloudinary.com/documentation/node_image_manipulation#direct_url_building

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM