Skip to content

ODataService UploadStream

UploadStream action is used to upload data stream to OData Properties with type Edm.Stream of an OData entity.

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

This action is not supported in ChangeSet.

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

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

ODataService UploadStream Properties

Property Type Required
Headers object Optional
Properties object Required
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

Properties

A list of the target entity's property names and values in key/value pairs format. Key is the name of the OData property with Edm.Stream type, Each value is a media content object in the following structure: {"content": binary, "contentType": string}. If an array is passed in, it's assumed it will contain the media content object and only the first item of the array will be used, the rest will be ignored.

  • 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.UploadStream"

Action Result

The ActionResult of this action is a JS object containing the uploaded entity.


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="ProductID"/>
  </Key>
  <Property Name="ProductID" 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 uploaded using this action.

Query Options

{
  "_Type": "Action.Type.ODataService.UploadStream",
  "Properties": {
    "HiResPhoto": "#Control:Attachment/#Value",
    "LoResPhoto": "/MyMDKApp/Rules/GenerateLoResPhoto.js"
  },
  "Target": {
    "Service": "/MyMDKApp/Services/MyOData.service",
    "EntitySet": "Products",
    "QueryOptions": "$filter=ProductID eq {ProductID}"
  }
}
{
  "_Type": "Action.Type.ODataService.UploadStream",
  "Properties": {
    "HiResPhoto": "#Control:Attachment/#Value",
    "LoResPhoto": "/MyMDKApp/Rules/GenerateLoResPhoto.js"
  },
  "Target" : {
    "Service" : "/MyMDKApp/Services/MyOData.service",
    "EntitySet" : "Products",
    "ReadLink": "{@odata.readLink}"
  }
}

Update Signature image

{
  "_Type": "Action.Type.ODataService.UploadStream",
  "Properties": {
    "HiResPhoto": ["#Control:SignatureCell/#Value"],
    "LoResPhoto": "/MyMDKApp/Rules/GenerateLoResPhoto.js"
  },
  "Target" : {
    "Service" : "/MyMDKApp/Services/MyOData.service",
    "EntitySet" : "Products",
    "ReadLink": "{@odata.readLink}"
  }
}