public class Asset extends Object
| Modifier and Type | Field and Description |
|---|---|
protected String |
assetUid |
protected String |
contentType |
protected String |
fileName |
protected String |
fileSize |
protected LinkedHashMap<String,Object> |
headerGroup_app |
protected LinkedHashMap<String,Object> |
headerGroup_local |
protected org.json.JSONObject |
json |
protected Stack |
stackInstance |
protected String[] |
tagsArray |
protected String |
uploadUrl |
org.json.JSONObject |
urlQueries |
| Modifier | Constructor and Description |
|---|---|
protected |
Asset() |
protected |
Asset(String assetUid) |
| Modifier and Type | Method and Description |
|---|---|
Asset |
addParam(String key,
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(FetchResultCallback callback)
Fetch a particular asset using uid.
|
String |
getAssetUid() |
Calendar |
getCreateAt() |
String |
getCreatedBy() |
Calendar |
getDeleteAt()
Get
Calendar value of deletion time of entry |
String |
getDeletedBy()
Get uid who deleted this entry.
|
String |
getFileName() |
String |
getFileSize() |
String |
getFileType() |
String[] |
getTags()
Get tags.
|
Calendar |
getUpdateAt()
Get
Calendar value of updating time of entry. |
String |
getUpdatedBy()
Get uid who updated this entry.
|
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(String key)
Remove a header for a given key from headers.
|
void |
setHeader(String key,
String value)
To set headers for Contentstack rest calls.
|
protected void |
setStackInstance(Stack stack) |
protected Asset |
setTags(String[] tags) |
protected void |
setUid(String assetUid)
To set uid of media file which is uploaded on Contentstack server.
|
org.json.JSONObject |
toJSON() |
protected String assetUid
protected String contentType
protected String fileSize
protected String fileName
protected String uploadUrl
protected org.json.JSONObject json
protected String[] tagsArray
public org.json.JSONObject urlQueries
protected LinkedHashMap<String,Object> headerGroup_app
protected LinkedHashMap<String,Object> headerGroup_local
protected Stack stackInstance
protected Asset()
protected Asset(String assetUid)
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.public void setHeader(String key, 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(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(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 String getAssetUid()
String uid = assetObject.getAssetUid(); return String of @uid
public String getFileType()
String contentType = assetObject.getFileType();
public String getFileSize()
String queueSize = assetObject.getFileSize();
public String getFileName()
String fileName = assetObject.getFileName();
public String getUrl()
String url = assetObject.getUrl();
public org.json.JSONObject toJSON()
Asset instance data.
JSONObject json = assetObject.toJSON();
public Calendar getCreateAt()
public String getCreatedBy()
public Calendar getUpdateAt()
Calendar value of updating time of entry.Date
Calendar updatedAt = assetObject.getUpdateAt("key");
public String getUpdatedBy()
String updatedBy_uid = assetObject.getUpdatedBy();
public Calendar getDeleteAt()
Calendar value of deletion time of entryDate
Calendar updatedAt = entry.getUpdateAt("key");
public String getDeletedBy()
String deletedBy_uid = assetObject.getDeletedBy();
public String[] getTags()
String[] tags = assetObject.getURL();
public Asset includeDimension()
public void fetch(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(String key, 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();
Copyright © 2021 Contentstack.. All rights reserved.