Skip to Content
1
Feb 08, 2021 at 09:36 AM

MDK Offline File Handling --> SAP Gateway

685 Views

Hello,

we have the following OData Entities modelled and implemented in SAP Gateway:

As you can see we have a "Product" Entity and 1..n attachments (MediaFile Entity) for each Product. The media entity is annotated with (hasStream ="true") and as you can see there is no dedicated property in the MediaFile Entity to pass the binary content to a caller. This is usually handled in SAP Gateway by adding a "/$value" to the end of the URL to tell the Gateway that the actual file content is requested instead of just the file metadata.

In my MDK app I want to use an attachment control to display the attachments for a product. Therefore I created an OData offline action to fetch the metadata for a file that is called when a product page is opened:

{
    "Service": "/TEST/Services/TestService.service",
    "DefiningRequests": [
    {
        "Name": "Product{Nodekey}",
        "Query": "{@odata.readLink}/ToMediaNav",
        "AutomaticallyRetrievesStreams": true
    }
],
    "_Type": "Action.Type.OfflineOData.Download",
    "ActionResult": {
        "_Name": "sync"
    },
    "OnFailure": "/TEST/Actions/Service/SyncFailureMessage.action",
    "OnSuccess": "/TEST/Rules/InitializeAttachments.js" 
}

As you can see I used the AutomaticallyRetrieveStreams property to tell the App that I also want to fetch the actual file content. However while this correctly reads the file metadata (filename, mime type, size etc.) from the back-end the $value request as mentioned earlier is never called. I can't see any further back-end calls by the framework at all when checking the logs. Since the documentation of AutomaticallyRetrieveStreams seems non existent can someone tell me what this acutally does? How should the odata back-end entity look like? Should it have a dedicated property of type Edm.Binary for the file content? Why does any "isMediaLocal" call in my MDK app returns "false"?

Thanks in advance

Tobias

Attachments

si8vc.png (12.6 kB)