<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: CAP - Node js - How to use binary data in deep structures? in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/cap-node-js-how-to-use-binary-data-in-deep-structures/qaa-p/12341152#M4622097</link>
    <description>&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;The issue is fixed. The fix to be provided with the next release of @sap/cds-runtime. You can follow CAP releases at &lt;A href="https://cap.cloud.sap/docs/releases/changelog/" target="test_blank"&gt;https://cap.cloud.sap/docs/releases/changelog/&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Vitaly&lt;/P&gt;</description>
    <pubDate>Thu, 18 Mar 2021 12:14:46 GMT</pubDate>
    <dc:creator>vitaly_kozyura</dc:creator>
    <dc:date>2021-03-18T12:14:46Z</dc:date>
    <item>
      <title>CAP - Node js - How to use binary data in deep structures?</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-node-js-how-to-use-binary-data-in-deep-structures/qaq-p/12341150</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
  &lt;P&gt;I tried to extend the media sample from &lt;A href="https://github.com/SAP-samples/cloud-cap-samples" target="test_blank"&gt;https://github.com/SAP-samples/cloud-cap-samples&lt;/A&gt; to check out how to display binary data in deep structures.&lt;/P&gt;
  &lt;P&gt;As example I created an entity Parent having a property "media" as an Composition of Media.&lt;/P&gt;
  &lt;P&gt;I deleted the media-service.js as to handle the calls automaticly by the default mechanism.&lt;/P&gt;
  &lt;P&gt;Then I added the Parent entity to the service. For test I added a new Parent object, created an "media" object and PUT the "Test.png" as the binary into it.&lt;/P&gt;
  &lt;P&gt;Extending the media.http I can view the binary when calling .../Media(1)/content. I also checked it in the Browser and can see, that it is served with Content-Type image/png. &lt;/P&gt;
  &lt;P&gt;When calling .../Parent(1)/media/content I get the object, but with the Content-Type application/octet-stream.&lt;/P&gt;
  &lt;P&gt;Has someone a solution how to get the object with the saved Content-Type, when reading it from a deep structure? Is that maybe a bug as it depends GET Request and not the saved object? &lt;/P&gt;
  &lt;P&gt;data-model.cds:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;namespace sap.capire.media;
entity Media {
 key id : Integer;
 @Core.MediaType : mediaType
 content : LargeBinary;
 @Core.IsMediaType : true
 mediaType : String;
 fileName : String;
 applicationName : String;
}
entity Parent {
 key id : Integer;
 media : Composition of Media;
}&lt;/CODE&gt;&lt;/PRE&gt;media-service.cds:
  &lt;PRE&gt;&lt;CODE&gt;using { sap.capire.media as db } from '../db/data-model';
namespace sap.capire.media;
service MediaServer {
 entity Media as projection on db.Media ;
 entity Parent as projection on db.Parent;
} &lt;/CODE&gt;&lt;/PRE&gt;media.http:
  &lt;PRE&gt;&lt;CODE&gt;### Requires REST Client for VS Code
### &lt;A href="https://marketplace.visualstudio.com/items?itemName=humao.rest-client" target="test_blank"&gt;https://marketplace.visualstudio.com/items?itemName=humao.rest-client&lt;/A&gt;
###
@protocol = http
@host = localhost
@port = 4004
### Read Pictures
GET {{protocol}}://{{host}}:{{port}}/media-server/Media
Authorization: Basic admin:
### Create Picture with mediatype
POST {{protocol}}://{{host}}:{{port}}/media-server/Parent
Authorization: Basic admin:
Accept: application/json
Content-Type: application/json
{ 
 "id": 1,
 "media":{
 "id": 1,
 "mediaType" : "image/jpeg"
 }
}
### Upload Binary PNG
PUT {{protocol}}://{{host}}:{{port}}/media-server/Parent(1)/media/content
Authorization: Basic admin:
Content-Type: image/png
&amp;lt; ./Test.png
### Read Binary
GET {{protocol}}://{{host}}:{{port}}/media-server/Media(1)/content
Authorization: Basic admin:
### Read Binary
GET {{protocol}}://{{host}}:{{port}}/media-server/Parent(1)/media/content
Authorization: Basic admin:
### Delete Image
DELETE {{protocol}}://{{host}}:{{port}}/media-server/Media(1)
Authorization: Basic admin:&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;best regards&lt;/P&gt;
  &lt;P&gt;Robert Quindt&lt;/P&gt;</description>
      <pubDate>Mon, 08 Mar 2021 13:23:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-node-js-how-to-use-binary-data-in-deep-structures/qaq-p/12341150</guid>
      <dc:creator>robert_quindt</dc:creator>
      <dc:date>2021-03-08T13:23:45Z</dc:date>
    </item>
    <item>
      <title>Re: CAP - Node js - How to use binary data in deep structures?</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-node-js-how-to-use-binary-data-in-deep-structures/qaa-p/12341151#M4622096</link>
      <description>&lt;P&gt;Hi Robin,&lt;/P&gt;&lt;P&gt;I can reproduce your issue.&lt;/P&gt;&lt;P&gt;We are looking into a fix.&lt;/P&gt;&lt;P&gt;Thanks for reporting!&lt;/P&gt;&lt;P&gt;Johannes&lt;/P&gt;</description>
      <pubDate>Wed, 10 Mar 2021 21:06:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-node-js-how-to-use-binary-data-in-deep-structures/qaa-p/12341151#M4622096</guid>
      <dc:creator>johannesvogel</dc:creator>
      <dc:date>2021-03-10T21:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: CAP - Node js - How to use binary data in deep structures?</title>
      <link>https://community.sap.com/t5/technology-q-a/cap-node-js-how-to-use-binary-data-in-deep-structures/qaa-p/12341152#M4622097</link>
      <description>&lt;P&gt;Hi Robert,&lt;/P&gt;&lt;P&gt;The issue is fixed. The fix to be provided with the next release of @sap/cds-runtime. You can follow CAP releases at &lt;A href="https://cap.cloud.sap/docs/releases/changelog/" target="test_blank"&gt;https://cap.cloud.sap/docs/releases/changelog/&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Vitaly&lt;/P&gt;</description>
      <pubDate>Thu, 18 Mar 2021 12:14:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/cap-node-js-how-to-use-binary-data-in-deep-structures/qaa-p/12341152#M4622097</guid>
      <dc:creator>vitaly_kozyura</dc:creator>
      <dc:date>2021-03-18T12:14:46Z</dc:date>
    </item>
  </channel>
</rss>

