Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // test.js
- const cloudinary = require('cloudinary').v2
- cloudinary.config({
- cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
- api_key: process.env.CLOUDINARY_API_KEY,
- api_secret: process.env.CLOUDINARY_API_SECRET,
- })
- // This 400's
- const imageURL =
- 'https://www.jcrew.com/s7-img-facade/AZ799_BR0910?fmt=jpeg&qlt=90,0&resMode=sharp&op_usm=.1,0,0,0&crop=0,0,0,0&wid=850&hei=850'
- // This works
- // const imageURL = 'http://cdn.shopify.com/s/files/1/0211/0338/products/211104JanessaLeoneEcom0241.jpg?v=1668115878'
- cloudinary.uploader
- .upload(imageURL, {
- folder: 'my_folder',
- width: '1000',
- quality: 'auto',
- })
- .then((result) => {
- console.log('Success: ', result.secure_url)
- return result.secure_url
- })
- .catch((e) => {
- console.log('error uploading to cloudinary', e)
- return imageURL
- })
- $ node test.js
- error uploading to cloudinary {
- message: 'Error in loading https://www.jcrew.com/s7-img-facade/AZ799_BR0910?fmt=jpeg&qlt=90,0&resMode=sharp&op_usm=.1,0,0,0&crop=0,0,0,0&wid=850&hei=850 - Request Timeout',
- name: 'Error',
- http_code: 400
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement