AssetLibrary
AssetLibrary
Get all asset from Stack
SetHeader
| Name | Type | Description |
|---|---|---|
| key | string | header name. |
| value | string | header value against given header name. |
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> asset = await stack.AssetLibrary().SetHeader("custom_key", "custom_value").FindAll();RemoveHeader
| Name | Type | Description |
|---|---|---|
| key | string | key to be remove from header |
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> asset = await stack.AssetLibrary("asset_uid").RemoveHeader("header_to_remove").FindAll();SortWithKeyAndOrderBy
| Name | Type | Description |
|---|---|---|
| key | string | Field UID |
| order | string | ordering for sorting from key |
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> asset = await stack.AssetLibrary().SortWithKeyAndOrderBy("field_uid", "order").FindAll();SetLocale
Sets the locale.
| Name | Type | Description |
|---|---|---|
| locale | string | Locale to be fetch |
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().SetLocale("en-us").FetchAll();Skip
The number of objects to skip before returning any.
| Name | Type | Description |
|---|---|---|
| number | int | No of objects to skip from returned objects. |
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().Skip(20).FetchAll();Limit
| Name | Type | Description |
|---|---|---|
| number | int | No of objects to limit. |
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().Limit(20).FetchAll();IncludeBranch
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().IncludeBranch().FindAll();IncludeCount
This method also includes the total number of assets returned in the response.
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().IncludeCount().FindAll();IncludeFallback
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().IncludeFallback().FindAll();IncludeMetadata
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().IncludeMetadata().FindAll();Except
Specifies list of field uids that would be excluded from the response.
| Name | Type | Description |
|---|---|---|
| fieldUids | System.String[] |
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
AssetLibrary assetLibrary = await stack.AssetLibrary().Except(new String[]{"name", "description"}).FetchAll();Only
Specifies an array of 'only' keys in BASE object that would be 'included' in the response.
| Name | Type | Description |
|---|---|---|
| fieldUid | System.String[] |
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
AssetLibrary assetLibrary = await stack.AssetLibrary().Only(new String[]{"name", "description"}).FetchAll();IncludeRelativeUrls
This method includes the relative url of assets.
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().IncludeRelativeUrls().FindAll();FetchAll
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
ContentstackCollection<Asset> assets = await stack.AssetLibrary().FetchAll();Count
Total count of the asset in specified Stack
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
AssetLibrary assetLibrary = await stack.AssetLibrary().Count();Query
AssetLibrary Query allows you to retrieve assets that match specific query criteria, returning a comprehensive list of assets that meet the defined parameters.
| Name | Type | Description |
|---|---|---|
| queryObject | JsonObject | The query contains the parameters needed to fetch assets and supports nested structures when required. |
Example:
using Contentstack.Core;
using Contentstack.Core.Models;
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
JsonObject queryObject = new JsonObject
{
{ "filename", "image3.png" }
};
ContentstackCollection<Asset> assets = await stack.AssetLibrary().Query(queryObject).FetchAll();JsonObject queryObject = new JsonObject
{
{ "bank_offers.card_type", new JsonObject { ["$ne"] = "Debit Card" } }
};
Tags
The tags method retrieves all assets associated with the specified tag
| Name | Type | Description |
|---|---|---|
| tags | string[] | An array of tag strings used to filter assets; returns assets matching any specified tag. If null or empty, no tag filtering is applied. |
Example:
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
AssetLibrary assetLibrary = stack.AssetLibrary();
assetLibrary.Tags(new string[] {"banner"});
ContentstackCollection<Asset> assets = await assetLibrary.FetchAll();