createRelatedMedia

open suspend fun createRelatedMedia(entity: EntityValue, content: StreamBase, parent: EntityValue, property: Property)

See createRelatedMedia_(EntityValue, StreamBase, EntityValue, Property, HttpHeaders?, RequestOptions?).

Parameters

entity

Entity parameter.

content

Content parameter.

parent

Parent parameter.

property

Property parameter.


open suspend fun createRelatedMedia(entity: EntityValue, content: StreamBase, parent: EntityValue, property: Property, headers: HttpHeaders?)

See createRelatedMedia_(EntityValue, StreamBase, EntityValue, Property, HttpHeaders?, RequestOptions?).

Parameters

entity

Entity parameter.

content

Content parameter.

parent

Parent parameter.

property

Property parameter.

headers

Headers parameter.


open suspend fun createRelatedMedia(entity: EntityValue, content: StreamBase, parent: EntityValue, property: Property, headers: HttpHeaders?, options: RequestOptions?)

Create an media entity in the target system, related to a parent entity via a parent navigation property.

Example using proxy classes:
open fun createRelatedMediaExample(): kotlin.Unit
{
    val service = this.service;
    val artist = Artist();
    artist.firstName = "Salvador";
    artist.lastName = "Dali";
    artist.dateOfBirth = LocalDate.of(1904, 5, 11);
    artist.placeOfBirth = GeographyPoint.withLatitudeLongitude(42.266667,
        2.965);
    service.createEntity(artist);
    val image = Image();
    image.label = "Dream";
    val content = ByteStream.fromBinary(com.sap.cloud.mobile.kotlin.odata.core.StringFunction.toBinary("Dream Caused by the Flight of a Bee around a Pomegranate a Second Before Awakening"));
    content.mediaType = "text/plain";
    service.createRelatedMedia(image, content, artist, Artist.images);
}
Example using dynamic API:
open fun createRelatedMediaExample(): kotlin.Unit
{
    val service = this.service;
    val artistsEntitySet = service.getEntitySet("Artists");
    val artistEntityType = artistsEntitySet.entityType;
    val firstNameProperty = artistEntityType.getProperty("firstName");
    val lastNameProperty = artistEntityType.getProperty("lastName");
    val dateOfBirthProperty = artistEntityType.getProperty("dateOfBirth");
    val placeOfBirthProperty = artistEntityType.getProperty("placeOfBirth");
    val imagesProperty = artistEntityType.getProperty("images");
    val imagesEntitySet = service.getEntitySet("Images");
    val imageEntityType = imagesEntitySet.entityType;
    val labelProperty = imageEntityType.getProperty("label");
    val artist = EntityValue.ofType(artistEntityType);
    firstNameProperty.setString(artist, "Maurits");
    lastNameProperty.setString(artist, "Escher");
    dateOfBirthProperty.setValue(artist, LocalDate.of(1898, 6, 17));
    placeOfBirthProperty.setValue(artist,
        GeographyPoint.withLatitudeLongitude(53.2, 5.783333));
    service.createEntity(artist);
    val image = EntityValue.ofType(imageEntityType);
    labelProperty.setString(image, "Hands");
    val content = ByteStream.fromBinary(com.sap.cloud.mobile.kotlin.odata.core.StringFunction.toBinary("Drawing Hands"));
    content.mediaType = "text/plain";
    service.createRelatedMedia(image, content, artist, imagesProperty);
}

Parameters

entity

Entity to be created.

content

Initial content. Must be a {@link com.sap.cloud.mobile.kotlin.odata.ByteStream} or {@link com.sap.cloud.mobile.kotlin.odata.CharStream}. Will be closed before this function returns.

parent

Previously created parent entity.

property

Parent's navigation property.

headers

(nullable) Optional request-specific headers.

options

(nullable) Optional request-specific options.