Skip to Content
avatar image
Former Member

Can someone explain attachment handling in Fiori/SAPUI5

We're working right now on a Fiori app and we want to show attachment files. That's I've investigated the "Approve Purchase Order". As far as I understand the ODATA Service delivers only metadata information.

<EntityType Name="Attachment" m:HasStream="true" sap:content-version="1">
<Key>   
<PropertyRef Name="AttachmentGuid" />
</Key>
<Property Name="AttachmentGuid" Type="Edm.String" Nullable="false" MaxLength="46" />
<Property Name="PrNumber" Type="Edm.String" MaxLength="10" sap:label="Objekt-ID" />
<Property Name="ItemNumber" Type="Edm.String" MaxLength="5" sap:label="Zeilen-ID" />
<Property Name="Description" Type="Edm.String" MaxLength="40" sap:label="Beschreibung" />
<Property Name="FileName" Type="Edm.String" MaxLength="255" sap:label="Komponentenname" />
<Property Name="MimeType" Type="Edm.String" MaxLength="128" sap:label="MIME Typ" />
<Property Name="FileSize" Type="Edm.String" MaxLength="12" />
<Property Name="CreatedByID" Type="Edm.String" MaxLength="12" sap:label="Benutzername" />
<Property Name="CreatedByName" Type="Edm.String" MaxLength="40" sap:label="Char" />
<Property Name="CreatedAt" Type="Edm.DateTime" Precision="0" sap:label="Zeitstempel" />
</EntityType>

This information is shown in a StandarListItem. The "press" action is "onAttachment" and here is the (few) code lines:

onAttachment: function(oEvent) { var oContext = oEvent.getSource().getBindingContext(); var sMediaSrc = oContext.getProperty().__metadata.media_src; sap.m.URLHelper.redirect(sMediaSrc, false);

},

I have no idea hiw it works. What is "__metadata.media_src" and where is it defined? I would expect at least the file name here.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Jul 03, 2015 at 05:43 AM

    In the meantime I've found a got blog regarding to this topic. It explains all of my questions.

    How to Read Photo from SAP system using SAP Gateway

    As you can see in this blog you will get this special "media_src" metadata field if you mark the "media" option on your entity definition in SEGW. But you have to implement get_stream in this case.

    Add comment
    10|10000 characters needed characters exceeded

  • Jun 02, 2015 at 02:27 PM

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thank you for the links. Some of them I've already found. But they don't help me.

      I want to understand the code of Approve Purchase Order app. As far as I understand it just delivers the attachment metadata like name and file size. I don't understand the code of the "onAttachment" method.

      What is "__metadata.media_src"?

      And "sap.m.URLHelper.redirect" opens just a link. Is this a link to the backend system?