Skip to content

ODataService DownloadMedia

Download Media action is used to download the associated media stream of a Media Entity (an OData EntityType with HasStream="true" attribute) to the device.

This action is not supported in ChangeSet.

Note: This action cannot be used to download data stream of OData property with "Edm.Stream" type of an EntityType. Please use Action.Type.ODataService.DownloadStream instead.

The properties defined in Action are also applicable to this action.

ODataService DownloadMedia Properties

Property Type Required
Headers object Optional
RequestOptions RequestOptions Optional
Target LinkQueryTarget Required
_Type const Required

Headers

Custom headers to be included as part of the request to the OData Service in key/value pair format

  • type: object

RequestOptions

Options for processing of data requests


Target

This action can only be executed on a single entity. therefore the Target specifier must be configured to return only 1 entity, otherwise this action will fail


_Type

  • type: const

The value of this property must be equal to:

"Action.Type.ODataService.DownloadMedia"

Action Result

Refer to the MDK Guide to understand what an action result is.

The success ActionResult of this action is the stream data of the downloaded media. The failure ActionResult is an error message.


Examples

OData Media entity

"Product" EntityType is a Media Entity and it has an associated media stream (could be a product image) that can be downloaded:

<EntityType Name="Product" HasStream="true">
  <Key>
    <PropertyRef Name="ID"/>
  </Key>
  <Property Name="ID" Type="Edm.String" Nullable="false"/>
  <Property Name="Name" Type="Edm.String" Nullable="false"/>
  <Property Name="Price" Type="Edm.Decimal" Nullable="false"/>
</EntityType>

Note: Each entity can only have a single associated media stream.

Query Options

{
  "_Type": "Action.Type.ODataService.DownloadMedia",
  "Target": {
    "Service": "/MyMDKApp/Services/MyOData.service",
    "EntitySet": "Images",
    "QueryOptions": "$filter=id eq {id}"
  }
}
{
  "_Type": "Action.Type.ODataService.DownloadMedia",
  "Target": {
    "Service": "/MyMDKApp/Services/MyOData.service",
    "EntitySet": "Images",
    "ReadLink": "{@odata.readLink}"
  }
}