public class Asset
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
assetUid |
protected java.lang.String |
contentType |
protected java.lang.String |
fileName |
protected java.lang.String |
fileSize |
protected android.util.ArrayMap<java.lang.String,java.lang.Object> |
headerGroup_app |
protected android.util.ArrayMap<java.lang.String,java.lang.Object> |
headerGroup_local |
protected org.json.JSONObject |
json |
protected Stack |
stackInstance |
protected java.lang.String[] |
tagsArray |
protected java.lang.String |
uploadUrl |
Modifier | Constructor and Description |
---|---|
protected |
Asset() |
protected |
Asset(java.lang.String assetUid) |
Modifier and Type | Method and Description |
---|---|
Asset |
addParam(java.lang.String key,
java.lang.String value)
This method adds key and value to an Entry.
|
Asset |
configure(org.json.JSONObject jsonObject)
Creates new instance of
Asset from valid JSONObject . |
void |
fetch(com.contentstack.sdk.FetchResultCallback callback)
Fetch a particular asset using uid.
|
java.lang.String |
getAssetUid()
Returns media file upload uid.
|
java.util.Calendar |
getCreateAt()
Get
Calendar value of creation time of entry. |
java.lang.String |
getCreatedBy()
Get uid who created this entry.
|
java.util.Calendar |
getDeleteAt()
Get
Calendar value of deletion time of entry. |
java.lang.String |
getDeletedBy()
Get uid who deleted this entry.
|
java.lang.String |
getFileName()
Returns file name of the uploaded file.
|
java.lang.String |
getFileSize()
Returns file queueSize of the uploaded file.
|
java.lang.String |
getFileType()
Returns content type of the uploaded file.
|
java.lang.String[] |
getTags()
Get tags.
|
java.util.Calendar |
getUpdateAt()
Get
Calendar value of updating time of entry. |
java.lang.String |
getUpdatedBy()
Get uid who updated this entry.
|
java.lang.String |
getUrl()
Returns upload url by which you can download media file uploaded on Built.io Contentstack server.
|
Asset |
includeDimension()
Include the dimensions (height and width) of the image in the response.
|
Asset |
includeFallback()
Retrieve the published content of the fallback locale if an entry is not localized in specified locale
|
void |
removeHeader(java.lang.String key)
Remove a header for a given key from headers.
|
void |
setCachePolicy(com.contentstack.sdk.CachePolicy cachePolicy)
To set cache policy using
Query instance. |
void |
setHeader(java.lang.String key,
java.lang.String value)
To set headers for Built.io Contentstack rest calls.
|
protected void |
setStackInstance(Stack stack) |
protected Asset |
setTags(java.lang.String[] tags)
To set tags for this objects
|
protected void |
setUid(java.lang.String assetUid)
To set uid of media file which is uploaded on Built.io Contentstack server.
|
org.json.JSONObject |
toJSON()
Returns JSON representation of this
Asset instance data. |
protected java.lang.String assetUid
protected java.lang.String contentType
protected java.lang.String fileSize
protected java.lang.String fileName
protected java.lang.String uploadUrl
protected org.json.JSONObject json
protected java.lang.String[] tagsArray
protected android.util.ArrayMap<java.lang.String,java.lang.Object> headerGroup_app
protected android.util.ArrayMap<java.lang.String,java.lang.Object> headerGroup_local
protected Stack stackInstance
protected void setStackInstance(Stack stack)
public Asset configure(org.json.JSONObject jsonObject)
Asset
from valid JSONObject
.
If JSON object is not appropriate then it will return null.jsonObject
- json object of particular file attached in the built object.Asset
can be generate using of data filled Entry
and configure(JSONObject)
.//'blt5d4sample2633b' is a dummy Application API key Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "bltdtsample_accessToken767vv", config); Asset assetObject = stack.asset("assetUid");
assetObject.configure(entryObject.getJSONObject(attached_image_field_uid));
JSONArray array = entryObject.getJSONArray(Attach_Image_Field_Uid);
for (int i = 0; i < array.length(); i++) {
Asset assetObject = stack.asset("assetUid");
assetObject.configure(entryObject.getJSONObject(attached_image_field_uid));
}
Asset
instance.public void setHeader(java.lang.String key, java.lang.String value)
key
- header name.value
- header value against given header name.
//'blt5d4sample2633b' is a dummy Application API key Asset assetObject = Contentstack.stack(context, "blt5d4sample2633b", "bltdtsample_accessToken767vv", config).asset("assetUid"); assetObject.setHeader("custom_header_key", "custom_header_value");
public void removeHeader(java.lang.String key)
key
- header key.
//'blt5d4sample2633b' is a dummy Application API key Asset assetObject = Contentstack.stack(context, "blt5d4sample2633b", "bltdtsample_accessToken767vv", config).asset("assetUid"); assetObject.removeHeader("custom_header_key");
protected void setUid(java.lang.String assetUid)
assetUid
- upload uid.
//'blt5d4sample2633b' is a dummy Application API key Asset assetObject = Contentstack.stack(context, "blt5d4sample2633b", "bltdtsample_accessToken767vv", config).asset("assetUid"); assetObject.setUid("upload_uid");
public java.lang.String getAssetUid()
String uid = assetObject.getAssetUid();
public java.lang.String getFileType()
String contentType = assetObject.getFileType();
public java.lang.String getFileSize()
Note :
file size will receive in bytes number.
Example :
String queueSize = assetObject.getFileSize();
public java.lang.String getFileName()
String fileName = assetObject.getFileName();
public java.lang.String getUrl()
String url = assetObject.getUrl();
public org.json.JSONObject toJSON()
Asset
instance data.
JSONObject json = assetObject.toJSON();
public java.util.Calendar getCreateAt()
Calendar
value of creation time of entry.
Calendar createdAt = assetObject.getCreateAt("key");
public java.lang.String getCreatedBy()
String createdBy_uid = assetObject.getCreatedBy();
public java.util.Calendar getUpdateAt()
Calendar
value of updating time of entry.
Calendar updatedAt = assetObject.getUpdateAt("key");
public java.lang.String getUpdatedBy()
String updatedBy_uid = assetObject.getUpdatedBy();
public java.util.Calendar getDeleteAt()
Calendar
value of deletion time of entry.
Calendar updatedAt = entry.getUpdateAt("key");
public java.lang.String getDeletedBy()
String deletedBy_uid = assetObject.getDeletedBy();
public java.lang.String[] getTags()
String[] tags = assetObject.getURL();
public void setCachePolicy(com.contentstack.sdk.CachePolicy cachePolicy)
Query
instance.cachePolicy
- CachePolicy
instance.
Query
object, so you can chain this call.
//'blt5d4sample2633b' is a dummy Stack API key //'blt6d0240b5sample254090d' is dummy access token. Stack stack = Contentstack.stack(context, "blt5d4sample2633b", "blt6d0240b5sample254090d", "stag", false); Asset assetObject = stack.asset("bltsampleAsset");
assetObject.setCachePolicy(NETWORK_ELSE_CACHE);
public void fetch(com.contentstack.sdk.FetchResultCallback callback)
callback
- FetchResultCallback
instance for success and failure result.
Asset asset = stack.asset("blt5312f71416d6e2c8"); asset.fetch(new FetchResultCallback() { @Override public void onCompletion(ResponseType responseType, Error error) { if(error == null){ //Success Block. }else { //Fail Block. } } });
protected Asset setTags(java.lang.String[] tags)
tags
- array of tag.Asset
object, so you can chain this call.
//'blt5d4sample2633b' is a dummy Application API key Asset assetObject = Contentstack.stack(context, "blt5d4sample2633b", "bltdtsample_accessToken767vv", config).asset("assetUid"); assetObject.setTags(new String[]{"tag1", "tag2"});
public Asset addParam(java.lang.String key, java.lang.String value)
key
- The key as string which needs to be added to an Assetvalue
- The value as string which needs to be added to an AssetAsset
final Asset asset = stack.asset("blt5312f71416d6e2c8"); asset.addParam("key", "some_value"); asset.fetch(new FetchResultCallback() { @Override public void onCompletion(ResponseType responseType, Error error) { if(error == null){ //Success Block. }else { //Fail Block. } } });
public Asset includeDimension()
public Asset includeFallback()
Asset
object, so you can chain this call.
Stack stack = Contentstack.stack(context, "ApiKey", "deliveryToken", "environment"); final Asset asset = stack.asset("asset_uid"); asset.includeFallback();