Class Cloudinary


  • public class Cloudinary
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      Cloudinary()  
      Cloudinary​(java.lang.String cloudinaryUrl)  
      Cloudinary​(java.util.Map config)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      Api api()  
      java.lang.String apiSignRequest​(java.util.Map<java.lang.String,​java.lang.Object> paramsToSign, java.lang.String apiSecret)  
      static java.util.Map asMap​(java.lang.Object... values)
      Deprecated.
      java.lang.String cloudinaryApiUrl​(java.lang.String action, java.util.Map options)  
      java.lang.String downloadArchive​(ArchiveParams params)  
      java.lang.String downloadArchive​(java.util.Map<java.lang.String,​java.lang.Object> options, java.lang.String targetFormat)  
      java.lang.String downloadBackedupAsset​(java.lang.String assetId, java.lang.String versionId, java.util.Map options)
      Returns an URL of a specific version of a backed up asset that can be used to download that version of the asset (within an hour of the request).
      java.lang.String downloadFolder​(java.lang.String folderPath, java.util.Map options)
      Generates URL for executing "Download Folder" operation on Cloudinary site.
      java.lang.String downloadGeneratedSprite​(java.lang.String[] urls, java.util.Map options)  
      java.lang.String downloadGeneratedSprite​(java.lang.String tag, java.util.Map options)  
      java.lang.String downloadMulti​(java.lang.String[] urls, java.util.Map options)  
      java.lang.String downloadMulti​(java.lang.String tag, java.util.Map options)  
      java.lang.String downloadZip​(java.util.Map<java.lang.String,​java.lang.Object> options)  
      java.lang.String getUserAgent()  
      java.lang.String privateDownload​(java.lang.String publicId, java.lang.String format, java.util.Map<java.lang.String,​java.lang.Object> options)  
      java.lang.String randomPublicId()  
      static void registerAPIStrategy​(java.lang.String className)  
      static void registerUploaderStrategy​(java.lang.String className)  
      Search search()  
      SearchFolders searchFolders()  
      void setAnalytics​(Analytics analytics)
      Set the analytics object that will be sent with every URL generation call.
      void setUserAgent​(java.lang.String prefix, java.lang.String version)
      Set the prefix and version for the user agent that will be sent with every API call a userAgent is built from `prefix/version (additional data)`
      java.lang.String signedPreloadedImage​(java.util.Map result)  
      void signRequest​(java.util.Map<java.lang.String,​java.lang.Object> params, java.util.Map<java.lang.String,​java.lang.Object> options)  
      Uploader uploader()  
      Url url()  
      boolean verifyApiResponseSignature​(java.lang.String publicId, java.lang.String version, java.lang.String signature)
      Verifies that Cloudinary API response is genuine by checking its signature.
      boolean verifyNotificationSignature​(java.lang.String body, java.lang.String timestamp, java.lang.String signature, long validFor)
      Verifies that Cloudinary notification request is genuine by checking its signature.
      java.lang.String zipDownload​(java.lang.String tag, java.util.Map<java.lang.String,​java.lang.Object> options)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • API_STRATEGIES

        public static java.util.List<java.lang.String> API_STRATEGIES
      • OLD_AKAMAI_SHARED_CDN

        public static final java.lang.String OLD_AKAMAI_SHARED_CDN
        See Also:
        Constant Field Values
      • AKAMAI_SHARED_CDN

        public static final java.lang.String AKAMAI_SHARED_CDN
        See Also:
        Constant Field Values
      • USER_AGENT_JAVA_VERSION

        public static final java.lang.String USER_AGENT_JAVA_VERSION
    • Constructor Detail

      • Cloudinary

        public Cloudinary​(java.util.Map config)
      • Cloudinary

        public Cloudinary​(java.lang.String cloudinaryUrl)
      • Cloudinary

        public Cloudinary()
    • Method Detail

      • api

        public Api api()
      • search

        public Search search()
      • registerUploaderStrategy

        public static void registerUploaderStrategy​(java.lang.String className)
      • registerAPIStrategy

        public static void registerAPIStrategy​(java.lang.String className)
      • url

        public Url url()
      • cloudinaryApiUrl

        public java.lang.String cloudinaryApiUrl​(java.lang.String action,
                                                 java.util.Map options)
      • randomPublicId

        public java.lang.String randomPublicId()
      • signedPreloadedImage

        public java.lang.String signedPreloadedImage​(java.util.Map result)
      • apiSignRequest

        public java.lang.String apiSignRequest​(java.util.Map<java.lang.String,​java.lang.Object> paramsToSign,
                                               java.lang.String apiSecret)
      • getUserAgent

        public java.lang.String getUserAgent()
        Returns:
        the userAgent that will be sent with every API call.
      • setUserAgent

        public void setUserAgent​(java.lang.String prefix,
                                 java.lang.String version)
        Set the prefix and version for the user agent that will be sent with every API call a userAgent is built from `prefix/version (additional data)`
        Parameters:
        prefix - - the prefix of the userAgent to be set
        version - - the version of the userAgent to be set
      • setAnalytics

        public void setAnalytics​(Analytics analytics)
        Set the analytics object that will be sent with every URL generation call.
        Parameters:
        analytics - - the analytics object to set
      • verifyNotificationSignature

        public boolean verifyNotificationSignature​(java.lang.String body,
                                                   java.lang.String timestamp,
                                                   java.lang.String signature,
                                                   long validFor)
        Verifies that Cloudinary notification request is genuine by checking its signature. Cloudinary can asynchronously process your e.g. image uploads requests. This is achieved by calling back API you specified during preparing of upload request as soon as it has been processed. See Upload Notifications in Cloudinary documentation for more details. In order to make sure it is Cloudinary calling your API back, hashed message authentication codes (HMAC's) based on agreed hashing function and configured Cloudinary API secret key are used for signing the requests. The following method serves as a convenient utility to perform the verification procedure.
        Parameters:
        body - Cloudinary Notification request body represented as string
        timestamp - Cloudinary Notification request custom X-Cld-Timestamp HTTP header value
        signature - Cloudinary Notification request custom X-Cld-Signature HTTP header value, i.e. the HMAC
        validFor - desired period of request validity since issued, in seconds, for protection against replay attacks
        Returns:
        whether request signature is valid or not
      • verifyApiResponseSignature

        public boolean verifyApiResponseSignature​(java.lang.String publicId,
                                                  java.lang.String version,
                                                  java.lang.String signature)
        Verifies that Cloudinary API response is genuine by checking its signature. Cloudinary can add a signature value in the response to API methods returning public id's and versions. In order to make sure it is genuine Cloudinary response, hashed message authentication codes (HMAC's) based on agreed hashing function and configured Cloudinary API secret key are used for signing the responses. The following method serves as a convenient utility to perform the verification procedure.
        Parameters:
        publicId - publicId response field value
        version - version response field value
        signature - signature response field value, i.e. the HMAC
        Returns:
        whether response signature is valid or not
      • signRequest

        public void signRequest​(java.util.Map<java.lang.String,​java.lang.Object> params,
                                java.util.Map<java.lang.String,​java.lang.Object> options)
      • privateDownload

        public java.lang.String privateDownload​(java.lang.String publicId,
                                                java.lang.String format,
                                                java.util.Map<java.lang.String,​java.lang.Object> options)
                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • zipDownload

        public java.lang.String zipDownload​(java.lang.String tag,
                                            java.util.Map<java.lang.String,​java.lang.Object> options)
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • downloadArchive

        public java.lang.String downloadArchive​(java.util.Map<java.lang.String,​java.lang.Object> options,
                                                java.lang.String targetFormat)
                                         throws java.io.UnsupportedEncodingException
        Throws:
        java.io.UnsupportedEncodingException
      • downloadArchive

        public java.lang.String downloadArchive​(ArchiveParams params)
                                         throws java.io.UnsupportedEncodingException
        Throws:
        java.io.UnsupportedEncodingException
      • downloadZip

        public java.lang.String downloadZip​(java.util.Map<java.lang.String,​java.lang.Object> options)
                                     throws java.io.UnsupportedEncodingException
        Throws:
        java.io.UnsupportedEncodingException
      • downloadGeneratedSprite

        public java.lang.String downloadGeneratedSprite​(java.lang.String tag,
                                                        java.util.Map options)
                                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • downloadGeneratedSprite

        public java.lang.String downloadGeneratedSprite​(java.lang.String[] urls,
                                                        java.util.Map options)
                                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • downloadMulti

        public java.lang.String downloadMulti​(java.lang.String tag,
                                              java.util.Map options)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • downloadMulti

        public java.lang.String downloadMulti​(java.lang.String[] urls,
                                              java.util.Map options)
                                       throws java.io.IOException
        Throws:
        java.io.IOException
      • downloadFolder

        public java.lang.String downloadFolder​(java.lang.String folderPath,
                                               java.util.Map options)
                                        throws java.io.UnsupportedEncodingException
        Generates URL for executing "Download Folder" operation on Cloudinary site.
        Parameters:
        folderPath - path of folder to generate download URL for
        options - optional, holds hints for URL generation procedure, see documentation for full list
        Returns:
        generated URL for downloading specified folder as ZIP archive
        Throws:
        java.io.UnsupportedEncodingException
      • downloadBackedupAsset

        public java.lang.String downloadBackedupAsset​(java.lang.String assetId,
                                                      java.lang.String versionId,
                                                      java.util.Map options)
                                               throws java.io.UnsupportedEncodingException
        Returns an URL of a specific version of a backed up asset that can be used to download that version of the asset (within an hour of the request).
        Parameters:
        assetId - The identifier of the uploaded asset.
        versionId - The identifier of a backed up version of the asset.
        options - Optional, holds hints for URL generation procedure, see documentation for full list
        Returns:
        The download URL of the asset
        Throws:
        java.io.UnsupportedEncodingException
      • asMap

        @Deprecated
        public static java.util.Map asMap​(java.lang.Object... values)
        Deprecated.