Skip to content

ODataService DownloadStream

DownloadStream action is used to download data stream of OData Properties with type Edm.Stream from an OData entity.

This action can download multiple Edm.Stream properties' data stream but only from a single entity, therefore, the result of the Target binding should only return a single entity, otherwise an error will be thrown.

This action doesn't support ChangeSet.

Note: This action cannot be used to download the associated data stream of a Media Entity (EntityType with HasStream="true"). Please use Action.Type.ODataService.DownloadMedia instead.

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

ODataService DownloadStream Properties

Property Type Required
DownloadOptions DownloadOptions Optional
Headers object Optional
Properties string[] Required
RequestOptions RequestOptions Optional
Target LinkQueryTarget Required
_Type const Required

DownloadOptions

Options for download stream requests

  • type: DownloadOptions[]

All array items must be of the type: DownloadOptions


Headers

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

  • type: object

Properties

A list of property names with Edm.Stream type in the target entity.

  • type: string[]

All items must be of the type: string


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.DownloadStream"

Action Result

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

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


Examples

OData entity with Edm.Stream properties

"HiResPhoto" and "LoResPhoto" properties are Edm.Stream in the following "Product" EntityType:

<EntityType Name="Product">
  <Key>
    <PropertyRef Name="ID"/>
  </Key>
  <Property Name="ID" Type="Edm.String" Nullable="false"/>
  <Property Name="Name" Type="Edm.String"/>
  <Property Name="Price" Type="Edm.Decimal" Nullable="false"/>
  <Property Name="HiResPhoto" Type="Edm.Stream" Nullable="true"/>
  <Property Name="LoResPhoto" Type="Edm.Stream" Nullable="true"/>
</EntityType>
Both data stream of "HiResPhoto" and "LoResPhoto" can be downloaded using this action.

Query Options

{
  "_Type": "Action.Type.ODataService.DownloadStream",
  "Target": {
    "Service": "/MyMDKApp/Services/MyOData.service",
    "EntitySet": "Products",
    "QueryOptions": "$filter=ProductID eq {ProductID}"
  },
  "Properties": ["Picture"]
}
{
  "_Type": "Action.Type.ODataService.DownloadStream",
  "Target": {
    "Service": "/MyMDKApp/Services/MyOData.service",
    "EntitySet": "Products",
    "ReadLink": "{@odata.readLink}"
  },
  "Properties": ["Picture"]
}

DownloadOptions

{
  "_Type": "Action.Type.ODataService.DownloadStream",
  "Target": {
    "Service": "/MyMDKApp/Services/MyOData.service",
    "EntitySet": "Products",
    "ReadLink": "{@odata.readLink}"
  },
  "Properties": ["Picture"],
  "DownloadOptions": [{
    "WriteToFilePath": "/MyMDKApp/Rules/GetFilePathName.js"
  }]
}