Class VdmMediaEntity<EntityT>

java.lang.Object
com.sap.cloud.sdk.datamodel.odata.helper.VdmObject<EntityT>
com.sap.cloud.sdk.datamodel.odata.helper.VdmEntity<EntityT>
com.sap.cloud.sdk.datamodel.odata.helper.VdmMediaEntity<EntityT>
Type Parameters:
EntityT - The specific entity type.

public abstract class VdmMediaEntity<EntityT> extends VdmEntity<EntityT>
Represents a media entity which exposes additional data under a $value endpoint.
  • Constructor Details

    • VdmMediaEntity

      public VdmMediaEntity()
  • Method Details

    • fetchMediaStream

      @Nonnull public InputStream fetchMediaStream() throws ODataException
      Get the binary data stream (file) from this media entity. Perform this operation after retrieving the entity object from the OData service.

      Alternatively, you can use this method to only retrieve the media resource without requesting the entity data. Build this entity via its .builder() and use VdmEntity.attachToService(String, Destination) to declare a service path and destination to request the media resource from. You can obtain the service path from the <ServiceClass>#DEFAULT_SERVICE_PATH, e.g. BusinessPartnerServiceBusinessPartnerService.DEFAULT_SERVICE_PATH

      Please ensure this stream is closed after usage. The below example achieves this using try-with-resources:

       try( InputStream content = entity.fetchMediaStream() ) {
           // do something with the content here
       }
       
      Returns:
      File content as an InputStream.
      Throws:
      ODataException - if the request could not be sent or the OData service responded with an error.
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class VdmEntity<EntityT>
    • canEqual

      protected boolean canEqual(@Nullable Object other)
      Overrides:
      canEqual in class VdmEntity<EntityT>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class VdmEntity<EntityT>