IResumableUpload.SaveFromStream Method 

IT Hit WebDAV for .NET

Saves segment of the resource from the specified stream to the WebDAV repository.

[Visual Basic]
Function SaveFromStream( _
   ByVal startIndex As Long, _
   ByVal totalContentLength As Long, _
   ByVal segment As Stream, _
   ByVal contentType As String _
) As WebDAVResponse
[C#]
WebDAVResponse SaveFromStream(
   long startIndex,
   long totalContentLength,
   Stream segment,
   string contentType
);

Parameters

startIndex
Index in file to which corresponds first byte in segment.
totalContentLength
Total size of the resource being uploaded. -1 if size is unknown.
segment
Stream with resource content segment.
contentType
Content type of the resource.

Return Value

Instance of WebDAVResponse representing operation status.

Remarks

If totalContentLength is -1 the segment parameter contains entire resource content. The startIndex parameter is always 0 in this case.

Example

 
public WebDAVResponse SaveFromStream(long startIndex, long totalContentLength, Stream segment, string contentType)
{
    if (!ClientHasToken)
        return new LockedResponse();

    long read = 0;
    try
    {
        read = WriteContent(segment, contentType, totalContentLength, startIndex);
    }
    catch (HttpListenerException)
    {
        //We came here because there were troubles with connection.
        //We want to keep content but return ResumeIncompleteResponse,
        //so engine knows we havn't finished uploading.
    }

    if (startIndex + read < totalContentLength)
    {
        return new ResumeIncompleteResponse();
    }
    else if (read > 0)
    {
        return new OkResponse();
    }
    else
    {
        return new NoContentResponse();
    }
}
 
 

See Also

IResumableUpload Interface | ITHit.WebDAV.Server.ResumableUpload Namespace