Try โ€‚โ€‰HackMD

Cloudinary

Developers and marketers use Cloudinary to quickly and easily create, manage and deliver their digital experiences across any browser, device and bandwidth.

Image upload

Signed

  • Authenticated requests (protected)

  • Set default upload presets as
    <sign-upload-preset-name-of-the-project-you-want-apply>

    Image Not Showing Possible Reasons
    • The image file may be corrupted
    • The server hosting the image is unavailable
    • The image path is incorrect
    • The image format is not supported
    Learn More โ†’

  • Only one project(signed upload preset) can be implement

    • Setting on bellow: (setting icon => upload(bottom) )
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More โ†’

    https://cloudinary.com/documentation/upload_presets#default_upload_presets

  • Required parameters :

    • file
    • api_key
    • public_id : file name
    • eager
    • timestamp
    • signature
  • .env (variable needed)

    • CLOUDINARY_API_KEY
    • CLOUDINARY_API_SECRET
  • Example: https://github.com/barrystone/social_app/blob/2a30f27fc65632c54eb05e50b3e50deb444ba03e/frontend/src/components/UpdateProfile.tsx

    • signature and timestamp (nodejs-react-typescript-crypto)

      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹  import Crypto from 'crypto';
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹  
      
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹  const timestamp = Math.round(Number(new Date()) / 1000);
      
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹  const signature = Crypto.createHash('sha256')
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹    .update(
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹      `eager=w_400,h_300,c_pad|w_260,h_200,c_crop&public_id=${public_id}&timestamp=${timestamp}${process.env.REACT_APP_CLOUDINARY_API_SECRET}`
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹    )
      โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹โ€‹    .digest('hex');
      

Unsigned