create Related Media
See createRelatedMedia_(EntityValue, StreamBase, EntityValue, Property, HttpHeaders?, RequestOptions?).
Parameters
Entity parameter.
Content parameter.
Parent parameter.
Property parameter.
See createRelatedMedia_(EntityValue, StreamBase, EntityValue, Property, HttpHeaders?, RequestOptions?).
Parameters
Entity parameter.
Content parameter.
Parent parameter.
Property parameter.
Headers parameter.
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 to be created.
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.
Previously created parent entity.
Parent's navigation property.
(nullable) Optional request-specific headers.
(nullable) Optional request-specific options.