Advertisement
Guest User

Untitled

a guest
Nov 15th, 2022
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. // test.js
  2. const cloudinary = require('cloudinary').v2
  3.  
  4. cloudinary.config({
  5. cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
  6. api_key: process.env.CLOUDINARY_API_KEY,
  7. api_secret: process.env.CLOUDINARY_API_SECRET,
  8. })
  9.  
  10. // This 400's
  11. const imageURL =
  12. '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'
  13.  
  14. // This works
  15. // const imageURL = 'http://cdn.shopify.com/s/files/1/0211/0338/products/211104JanessaLeoneEcom0241.jpg?v=1668115878'
  16.  
  17. cloudinary.uploader
  18. .upload(imageURL, {
  19. folder: 'my_folder',
  20. width: '1000',
  21. quality: 'auto',
  22. })
  23. .then((result) => {
  24. console.log('Success: ', result.secure_url)
  25. return result.secure_url
  26. })
  27. .catch((e) => {
  28. console.log('error uploading to cloudinary', e)
  29. return imageURL
  30. })
  31.  
  32.  
  33. $ node test.js
  34.  
  35. error uploading to cloudinary {
  36. 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',
  37. name: 'Error',
  38. http_code: 400
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement