From 045c9ea801e81f5cc311ac77f2faf87ab28b9880 Mon Sep 17 00:00:00 2001 From: David H Lam Date: Fri, 27 Jun 2025 12:10:32 +0200 Subject: [PATCH 1/2] Returning media data in actions and functions Added subsection about returning media data streams in custom actions and functions. --- cds/cdl.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cds/cdl.md b/cds/cdl.md index 36141c2387..8f6dbab2b0 100644 --- a/cds/cdl.md +++ b/cds/cdl.md @@ -2101,7 +2101,21 @@ service CatalogService { Explicitly modelled binding parameters are ignored for OData V2. +#### Returning Media Data Streams { #actions-returning-media} +Actions and functions can also be modelled to return streamed media data like images, CSVs, etc. In order to do so, the action or function's return type has to refer to a [predefined type](#types) annotated with [media data annotations](/guides/providing-services#annotating-media-elements) that is defined in the same service. The minimum set of annotations required is `@Core.MediaType`. + +```cds +service CatalogService { + @Core.MediaType: 'image/png' @Core.ContentDisposition.Filename: 'image.png' @Core.ContentDisposition.Type: 'attachment' + type png : LargeBinary; + + entity Products as projection on data.Products { ... } + actions { + function image() returns png; + } +} +``` ### Custom-Defined Events {#events} From a7e39feeabfcb41b394b9f6545d071ceeaff3242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Jeglinsky?= Date: Tue, 26 Aug 2025 13:15:22 +0200 Subject: [PATCH 2/2] Apply suggestions from code review --- cds/cdl.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cds/cdl.md b/cds/cdl.md index 8f6dbab2b0..22e6c1d3c4 100644 --- a/cds/cdl.md +++ b/cds/cdl.md @@ -2103,7 +2103,7 @@ Explicitly modelled binding parameters are ignored for OData V2. #### Returning Media Data Streams { #actions-returning-media} -Actions and functions can also be modelled to return streamed media data like images, CSVs, etc. In order to do so, the action or function's return type has to refer to a [predefined type](#types) annotated with [media data annotations](/guides/providing-services#annotating-media-elements) that is defined in the same service. The minimum set of annotations required is `@Core.MediaType`. +Actions and functions can also be modeled to return streamed media data such as images and CSV files. To achieve this, the return type of the actions or functions must refer to a [predefined type](#types), annotated with [media data annotations](/guides/providing-services#annotating-media-elements), that is defined in the same service. The minimum set of annotations required is `@Core.MediaType`. ```cds service CatalogService {