download Stream
See downloadStream_(EntityValue, StreamLink, HttpHeaders?, RequestOptions?).
Return
(see linked method).
Parameters
Entity parameter.
Link parameter.
See downloadStream_(EntityValue, StreamLink, HttpHeaders?, RequestOptions?).
Return
(see linked method).
Parameters
Entity parameter.
Link parameter.
Headers parameter.
Obtain a stream for downloading the content of a stream property from the target system. Caution: streams are often used for large content that may not fit (all at once) in available application memory. Having too many threads simultaneously downloading streams, or using {@link com.sap.cloud.mobile.kotlin.odata.ByteStream#readAndClose() ByteStream.readAndClose}, may result in out-of-memory conditions on memory-constrained devices.
- See Also:
-
{@link com.sap.cloud.mobile.kotlin.odata.DataServiceAsync#downloadToFile_(com.sap.cloud.mobile.kotlin.odata.EntityValue, com.sap.cloud.mobile.kotlin.odata.StreamLink, kotlin.String, com.sap.cloud.mobile.kotlin.odata.http.HttpHeaders?, com.sap.cloud.mobile.kotlin.odata.RequestOptions?) DataServiceAsync.downloadToFile}, {@link com.sap.cloud.mobile.kotlin.odata.Property#getStreamLink(com.sap.cloud.mobile.kotlin.odata.StructureBase) Property.getStreamLink}.
- Example using proxy classes:
open fun downloadStreamExample(): kotlin.Unit { val service = this.service; val query = DataQuery().filter(Video.label.equal("Happier")).top(1); val video = service.getVideo(query); val stream = service.downloadStream(video, video.content); val data = stream.readAndClose(); Assert.isTrue(BinaryOperator.equal(data, com.sap.cloud.mobile.kotlin.odata.core.StringFunction.toBinary("happy-stuff")), "/Users/home/xmkbuilder/data/jenkins/prod-build7010/w/a1o59enhtx/src/main/xs/examples/example.MediaProxyClient.xs:129:9"); Assert.isTrue(NullableString.hasValue(stream.mediaType, "text/plain"), "/Users/home/xmkbuilder/data/jenkins/prod-build7010/w/a1o59enhtx/src/main/xs/examples/example.MediaProxyClient.xs:130:9"); }
- Example using dynamic API:
open fun downloadStreamExample(): kotlin.Unit { val service = this.service; val videosEntitySet = service.getEntitySet("Videos"); val videoEntityType = videosEntitySet.entityType; val labelProperty = videoEntityType.getProperty("label"); val contentProperty = videoEntityType.getProperty("content"); val query = DataQuery().from(videosEntitySet).filter(labelProperty.equal("Happier")) .top(1); val video = service.executeQuery(query).getRequiredEntity(); val link = contentProperty.getStreamLink(video); val stream = service.downloadStream(video, link); val data = stream.readAndClose(); Assert.isTrue(BinaryOperator.equal(data, com.sap.cloud.mobile.kotlin.odata.core.StringFunction.toBinary("...")), "/Users/home/xmkbuilder/data/jenkins/prod-build7010/w/a1o59enhtx/src/main/xs/examples/example.MediaClient.xs:158:9"); Assert.isTrue(NullableString.hasValue(stream.mediaType, "text/plain"), "/Users/home/xmkbuilder/data/jenkins/prod-build7010/w/a1o59enhtx/src/main/xs/examples/example.MediaClient.xs:159:9"); }
Return
A stream for downloading the content of a stream property. This must be closed by the caller, or else a resource leak may occur.
Parameters
Entity containing the stream property whose content is to be downloaded.
Stream link for the stream to be downloaded.
(nullable) Optional request-specific headers.
(nullable) Optional request-specific options.