Skip to content

ODataService UploadMedia

Upload Media action is used to upload one or multiple OData Media Entities. Action are also applicable to this action.

ODataService UploadMedia Properties

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

Media

If the array contains multiple items, multiple Media Entities will be created.

  • type: object[]

The actual value of the media. Should be in this format {"content":binary, "contentType":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.UploadMedia"

Action Result

The ActionResult of this action is a JS array of OData media entities.


Examples

OData Media entity

"Image" EntityType is a Media Entity.

<EntityType Name="Image" HasStream="true">
  <Key>
    <PropertyRef Name="ID"/>
  </Key>
  <Property Name="ID" Type="Edm.String" Nullable="false"/>
  <Property Name="Name" Type="Edm.String" Nullable="false"/>
</EntityType>
...
...
<EntitySet Name="Image" EntityType="MyODataModel.Image"/>

Note: Uploads media, it replaces if it has any existing media. UploadMedia action is for MediaEntity. UploadStream action is for normal Entity, if the property type is Edm.Stream.

UploadMedia from Attachment control

{
  "_Type": "Action.Type.ODataService.UploadMedia",
  "Target": {
    "Service": "/MyMDKApp/Services/MyOData.service",
    "EntitySet": "Images",
    "ReadLink": "{@odata.readLink}"
  },
  "Media":"#Control:Attachment/#Value",
  "ActionResult" : { "_Name" : "OData" },
  "OnSuccess": "/MyMDKApp/Actions/ClosePage.action",
  "OnFailure": "/MyMDKApp/Rules/Failure.js"
}

{
  "_Type": "Action.Type.ODataService.UploadMedia",
  "Target": {
    "Service": "/MyMDKApp/Services/MyOData.service",
    "EntitySet": "Images",
    "QueryOptions": "$filter=ID eq 1234"
  },
  "Media":"#Control:Attachment/#Value",
  "ActionResult" : { "_Name" : "OData" },
  "OnSuccess": "/MyMDKApp/Actions/ClosePage.action",
  "OnFailure": "/MyMDKApp/Rules/Failure.js"
}