Package com.contentstack.sdk
Class AssetLibrary
java.lang.Object
com.contentstack.sdk.AssetLibrary
- All Implemented Interfaces:
INotifyClass
public class AssetLibrary extends Object implements INotifyClass
Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded to Contentstack.
These files can be used in multiple entries.
Read more about [Assets](https://www.contentstack.com/docs/guide/content-management#working-with-assets)
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAssetLibrary.ORDERBYSorting order enum forAssetLibrary. -
Field Summary
Fields Modifier and Type Field Description org.json.JSONObjecturlQueries -
Constructor Summary
Constructors Modifier Constructor Description protectedAssetLibrary() -
Method Summary
Modifier and Type Method Description voidfetchAll(FetchAssetsCallback assetsCallback)Fetch a all asset.intgetCount()Get a count of assets in success callback ofFetchAssetsCallback.voidgetResult(Object object, String controller)voidgetResultObject(List<Object> objects, org.json.JSONObject jsonObject, boolean isSingleEntry)AssetLibraryincludeCount()Retrieve count and data of assets in result.AssetLibraryincludeFallback()Retrieve the published content of the fallback locale if an entry is not localized in specified localeAssetLibraryincludeRelativeUrl()Retrieve relative urls objects in result.voidremoveHeader(String key)Remove a header for a given key from headers.voidsetHeader(String key, String value)To set headers for Contentstack rest calls.protected voidsetStackInstance(Stack stack)AssetLibrarysort(String key, AssetLibrary.ORDERBY orderby)Sort assets by fieldUid.
-
Field Details
-
urlQueries
public org.json.JSONObject urlQueries
-
-
Constructor Details
-
AssetLibrary
protected AssetLibrary()
-
-
Method Details
-
setStackInstance
-
setHeader
To set headers for Contentstack rest calls.
Scope is limited to this object only.- Parameters:
key- header name.value- header value against given header name.
Example :
//'blt5d4sample2633b' is a dummy Application API key AssetLibrary assetLibObject = Contentstack.stack("blt5d4sample2633b", "bltdtsample_accessToken767vv", config).assetLibrary(); assetLibObject.setHeader("custom_header_key", "custom_header_value");
-
removeHeader
Remove a header for a given key from headers.
Scope is limited to this object only.- Parameters:
key- header key.
Example :
//'blt5d4sample2633b' is a dummy Application API key AssetLibrary assetLibObject = Contentstack.stack("blt5d4sample2633b", "bltdtsample_accessToken767vv", config).assetLibrary(); assetLibObject.removeHeader("custom_header_key");
-
sort
Sort assets by fieldUid.- Parameters:
key- field Uid.orderby-AssetLibrary.ORDERBYvalue for ascending or descending.- Returns:
AssetLibraryobject, so you can chain this call.
Example :
//'blt5d4sample2633b' is a dummy Application API key AssetLibrary assetLibObject = Contentstack.stack("blt5d4sample2633b", "bltdtsample_accessToken767vv", config).assetLibrary(); assetLibObject.sort("fieldUid", AssetLibrary.ORDERBY.ASCENDING);
-
includeCount
Retrieve count and data of assets in result.- Returns:
AssetLibraryobject, so you can chain this call.
Example :
//'blt5d4sample2633b' is a dummy Stack API key //'bltdtsample_accessToken767vv' is dummy access token. AssetLibrary assetLibObject = Contentstack.stack( "blt5d4sample2633b", "bltdtsample_accessToken767vv", config).assetLibrary(); assetLibObject.includeCount();
-
includeRelativeUrl
Retrieve relative urls objects in result.- Returns:
AssetLibraryobject, so you can chain this call.
Example :
//'blt5d4sample2633b' is a dummy Stack API key //'bltdtsample_accessToken767vv' is dummy access token. AssetLibrary assetLibObject = Contentstack.stack( "blt5d4sample2633b", "bltdtsample_accessToken767vv", config).assetLibrary(); assetLibObject.includeRelativeUrl();
-
getCount
public int getCount()Get a count of assets in success callback ofFetchAssetsCallback.- Returns:
- int @count
-
fetchAll
Fetch a all asset.- Parameters:
assetsCallback-FetchAssetsCallbackinstance for success and failure result.
Example :
AssetLibrary assetLibObject = Contentstack.stack("blt5d4sample2633b", "bltdtsample_accessToken767vv", config).assetLibrary(); assetLibObject.fetchAll(new FetchAssetsCallback() {public void onCompletion(ResponseType responseType, List<Asset> assets, Error error){ if (error == null) { //Success Block. } else { //Error Block. } } });
-
getResult
- Specified by:
getResultin interfaceINotifyClass
-
getResultObject
public void getResultObject(List<Object> objects, org.json.JSONObject jsonObject, boolean isSingleEntry)- Specified by:
getResultObjectin interfaceINotifyClass
-
includeFallback
Retrieve the published content of the fallback locale if an entry is not localized in specified locale- Returns:
AssetLibraryobject, so you can chain this call.
Example :
Stack stack = Contentstack.stack( "ApiKey", "deliveryToken", environment_name); AssetLibrary assetLibObject = stack.assetLibrary(); assetLibObject.includeFallback();
-