Package com.contentstack.sdk
Class Asset
- java.lang.Object
-
- com.contentstack.sdk.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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Asset
addParam(String paramKey, String paramValue)
Add param asset.Asset
configure(org.json.JSONObject jsonObject)
Configure asset.void
fetch(FetchResultCallback callback)
Fetch.String
getAssetUid()
Gets asset uid.Calendar
getCreateAt()
Gets create at.String
getCreatedBy()
Gets created by.Calendar
getDeleteAt()
Gets delete at.String
getDeletedBy()
Gets deleted by.String
getFileName()
Gets file name.String
getFileSize()
Gets file size.String
getFileType()
Gets file type.String[]
getTags()
Get tags string [ ].Calendar
getUpdateAt()
Gets update at.String
getUpdatedBy()
Gets updated by.String
getUrl()
Gets url.Asset
includeBranch()
Includes Branch in the asset responseAsset
includeDimension()
Include dimension asset.Asset
includeFallback()
Include fallback asset.Asset
includeMetadata()
Includes Metadata in the asset responsevoid
removeHeader(String headerKey)
The function removes a header from a collection of headers based on a given key.void
setHeader(String headerKey, String headerValue)
Sets header.org.json.JSONObject
toJSON()
To json json object.
-
-
-
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 keyheaderValue
- 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 keyparamValue
- 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
-
-