Class Asset


  • public class Asset
    extends Object
    Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded in your Contentstack repository for future use. These files can be attached and used in multiple entries.

    You can now pass the branch header in the API request to fetch or manage modules located within specific branches of the stack.

    Since:
    01-11-2017
    Version:
    1.0.0
    Author:
    Shailesh Mishra
    • Method Detail

      • configure

        public Asset configure​(org.json.JSONObject jsonObject)
        Configure asset.
        Parameters:
        jsonObject - the json object
        Returns:
        the asset
      • setHeader

        public void setHeader​(@NotNull
                              String headerKey,
                              @NotNull
                              String headerValue)
        Sets header.
        Parameters:
        headerKey - the header key
        headerValue - the header value

        Example :

        Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); Asset asset = stack.asset(asset_uid); asset.setHeader();

      • removeHeader

        public void removeHeader​(@NotNull
                                 String headerKey)
        The function removes a header from a collection of headers based on a given key.
        Parameters:
        headerKey - The parameter "headerKey" is a String that represents the key of the header to be removed.
        Example :

        Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); Asset asset = stack.asset(asset_uid); asset.removeHeader();

      • getAssetUid

        public String getAssetUid()
        Gets asset uid.
        Returns:
        the asset uid

        Example :
        Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); Asset asset = stack.asset(asset_uid); asset.fetch(new FetchResultCallback() { @Override public void onCompletion(ResponseType responseType, Error error) { asset.getAssetUid(); } });
      • getFileType

        public String getFileType()
        Gets file type.
        Returns:
        the file type

        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.fetch(new FetchResultCallback() {
                     @Override
                     public void onCompletion(ResponseType responseType, Error error) {
                         asset.getFileType();
                     }
                 });
                 
      • getFileSize

        public String getFileSize()
        Gets file size.
        Returns:
        the file size

        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.fetch(new FetchResultCallback() {
                     @Override
                     public void onCompletion(ResponseType responseType, Error error) {
                         asset.getFileSize();
                     }
                 });
        
                 
      • getFileName

        public String getFileName()
        Gets file name.
        Returns:
        the file name

        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.fetch(new FetchResultCallback() {
                     @Override
                     public void onCompletion(ResponseType responseType, Error error) {
                         asset.getFileName();
                     }
                 });
        
                 
      • getUrl

        public String getUrl()
        Gets url.
        Returns:
        the url

        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.fetch(new FetchResultCallback() {
                     @Override
                     public void onCompletion(ResponseType responseType, Error error) {
                         asset.getUrl();
                     }
                 });
        
                 
      • toJSON

        public org.json.JSONObject toJSON()
        To json json object.
        Returns:
        the json object

        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.fetch(new FetchResultCallback() {
                     @Override
                     public void onCompletion(ResponseType responseType, Error error) {
                         asset.toJSON();
                     }
                 });
        
                 
      • getCreateAt

        public Calendar getCreateAt()
        Gets create at.
        Returns:
        the create at
        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.fetch(new FetchResultCallback() {
                     @Override
                     public void onCompletion(ResponseType responseType, Error error) {
                         asset.getCreateAt();
                     }
                 });
        
                 
      • getCreatedBy

        public String getCreatedBy()
        Gets created by.
        Returns:
        the created by

        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.fetch(new FetchResultCallback() {
                     @Override
                     public void onCompletion(ResponseType responseType, Error error) {
                         asset.getCreatedBy();
                     }
                 });
        
                 
      • getUpdateAt

        public Calendar getUpdateAt()
        Gets update at.
        Returns:
        the update at

        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.fetch(new FetchResultCallback() {
                     @Override
                     public void onCompletion(ResponseType responseType, Error error) {
                         asset.getUpdateAt();
                     }
                 });
        
                 
      • getUpdatedBy

        public String getUpdatedBy()
        Gets updated by.
        Returns:
        the updated by

        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.fetch(new FetchResultCallback() {
                     @Override
                     public void onCompletion(ResponseType responseType, Error error) {
                         asset.getUpdatedBy();
                     }
                 });
        
                 
      • getDeleteAt

        public Calendar getDeleteAt()
        Gets delete at.
        Returns:
        the delete at

        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.fetch(new FetchResultCallback() {
                     @Override
                     public void onCompletion(ResponseType responseType, Error error) {
                         asset.getDeleteAt();
                     }
                 });
        
                 
      • getDeletedBy

        public String getDeletedBy()
        Gets deleted by.
        Returns:
        the deleted by

        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.fetch(new FetchResultCallback() {
                     @Override
                     public void onCompletion(ResponseType responseType, Error error) {
                         asset.getDeletedBy();
                     }
                 });
                 
      • getTags

        public String[] getTags()
        Get tags string [ ].
        Returns:
        the string [ ]

        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.fetch(new FetchResultCallback() {
                     @Override
                     public void onCompletion(ResponseType responseType, Error error) {
                         asset.getTags();
                     }
                 });
        
                 
      • includeDimension

        public Asset includeDimension()
        Include dimension asset.
        Returns:
        the asset

        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.includeDimension();
                 
      • addParam

        public Asset addParam​(@NotNull
                              String paramKey,
                              @NotNull
                              String paramValue)
        Add param asset.
        Parameters:
        paramKey - the param key
        paramValue - the param value
        Returns:
        the asset

        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.addParam();
                 
      • includeFallback

        public Asset includeFallback()
        Include fallback asset.
        Returns:
        the asset

        Example :
                 Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment");
                 Asset asset = stack.asset(asset_uid);
                 asset.includeFallback();
                 
      • includeBranch

        public Asset includeBranch()
        Includes Branch in the asset response
        Returns:
        Asset object, so you can chain this call.


        Example :
        Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); Asset asset = stack.asset(asset_uid); asset.includeBranch();
      • includeMetadata

        public Asset includeMetadata()
        Includes Metadata in the asset response
        Returns:
        Asset object, so you can chain this call.


        Example :
        Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); Asset asset = stack.asset(asset_uid); asset.includeMetadata();
      • fetch

        public void fetch​(FetchResultCallback callback)
        Fetch.
        Parameters:
        callback - the callback