Media Resources

If you want to download, upload or delete streams on your WebService, you have to follow following steps:

Streaming functions

Download

Invoked when retrieving a MLE.

Syntax

IStream Download(T entity)

Parameters

Type

Name

Description

T

entity

The entity, for which the Streaming resource should be downloaded.

Return type

Returns an open and readable IStream object.

Remarks

The downloaded stream could be a FileStream oranything else.
MemoryStreams could be used too, but keep in mind that large data can couse memory problems!
A stream can be retrieved by sending this:

GET http://localhost:8080/TestBundle/TEST_SVC/TestMethod(1)/$value

Upload

Invoked when uploading a new stream to a MLE.

Syntax

void Upload(T entity, IStream stream)

Parameters

Type

Name

Description

T

entity

The entity, for which the streaming resource should be uploaded.

IStream

stream

The binary data from the request

Remarks

Get’s the MLE and an open and written IStream.
When working with large data, we consider to not read the stream-data into memory!

When performing a POST request, first the Create(T) function is called for creating the MLE itself.
The Slug-Header is used to create the MLE with the correct data.
Next the Upload function is called, for uploading the binary data.

A stream can be created by sending this request:

POST http://localhost:8080/TestBundle/TEST_SVC/TestMethod
Content-Length: '###'
Slug: Id=1

%PDF-1.4
...
%%EOF

When performing a PUT request on a MLE, the Upload-function is called with the new binary data.

For checking, if the Upload function was called for updating or creating a Stream, you can use the entity.Mode property.

A stream can be updated by sending a query with this structure:

PUT http://localhost:8080/TestBundle/TEST_SVC/TestMethod(1)
Content-Length: '###'
Slug: Id=1

%PDF-1.4

%%EOF

DeleteStream

Called when deleting the stream from a MLE.

Syntax

void DeleteStream(T entity)

Parameters

Type

Name

Description

T

entity

The entity, for which the streaming resource should be removed.

Remarks

When performing a DELETE request first the MLE becomes removed by calling the Delete-function.
After that, the remaining stream-resources will be removed by calling the DeleteStream function.