Skip to content

Commit f560ea0

Browse files
Returning media data in actions and functions (#1939)
Added subsection about returning media data streams in custom actions and functions. --------- Co-authored-by: René Jeglinsky <rene.jeglinsky@sap.com>
1 parent 775fc37 commit f560ea0

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

cds/cdl.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,7 +2096,21 @@ service CatalogService {
20962096

20972097
Explicitly modelled binding parameters are ignored for OData V2.
20982098

2099+
#### Returning Media Data Streams { #actions-returning-media}
20992100

2101+
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`.
2102+
2103+
```cds
2104+
service CatalogService {
2105+
@Core.MediaType: 'image/png' @Core.ContentDisposition.Filename: 'image.png' @Core.ContentDisposition.Type: 'attachment'
2106+
type png : LargeBinary;
2107+
2108+
entity Products as projection on data.Products { ... }
2109+
actions {
2110+
function image() returns png;
2111+
}
2112+
}
2113+
```
21002114

21012115
### Custom-Defined Events {#events}
21022116

0 commit comments

Comments
 (0)