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 java.util.LinkedHashMap<java.lang.String,java.lang.Object> |
headerGroup_app |
protected java.util.LinkedHashMap<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 |
org.json.JSONObject |
urlQueries |
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() |
java.util.Calendar |
getCreateAt() |
java.lang.String |
getCreatedBy() |
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() |
java.lang.String |
getFileSize() |
java.lang.String |
getFileType() |
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() |
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 |
setHeader(java.lang.String key,
java.lang.String value)
To set headers for Contentstack rest calls.
|
protected void |
setStackInstance(Stack stack) |
protected Asset |
setTags(java.lang.String[] tags) |
protected void |
setUid(java.lang.String assetUid)
To set uid of media file which is uploaded on Contentstack server.
|
org.json.JSONObject |
toJSON() |
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
public org.json.JSONObject urlQueries
protected java.util.LinkedHashMap<java.lang.String,java.lang.Object> headerGroup_app
protected java.util.LinkedHashMap<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
JSONObject
.//'blt5d4sample2633b' is a dummy Application API key Stack stack = Contentstack.stack("apiKey", "deliveryToken", "environment"); 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.protected Asset setTags(java.lang.String[] tags)
public void setHeader(java.lang.String key, java.lang.String value)
key
- header name.value
- header value against given header name.
Asset assetObject = Contentstack.stack( "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("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("blt5d4sample2633b", "bltdtsample_accessToken767vv", config).asset("assetUid"); assetObject.setUid("upload_uid");
public java.lang.String getAssetUid()
String uid = assetObject.getAssetUid(); return String of @uid
public java.lang.String getFileType()
String contentType = assetObject.getFileType();
public java.lang.String getFileSize()
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()
Date
Get Calendar
value of creation time of entry.
Calendar createdAt = assetObject.getCreateAt("key");
public java.lang.String getCreatedBy()
public java.util.Calendar getUpdateAt()
Calendar
value of updating time of entry.Date
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 entryDate
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 Asset includeDimension()
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. } } });
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 includeFallback()
Asset
object, so you can chain this call.
Stack stack = Contentstack.stack("ApiKey", "deliveryToken", "environment"); final Asset asset = stack.asset("asset_uid"); asset.includeFallback();