Click or drag to resize

IUploadProgress Interface

IT Hit WebDAV Classes Reference
Implemented on files and folders to report upload progress.

Namespace:  ITHit.WebDAV.Server.ResumableUpload
Assembly:  ITHit.WebDAV.Server (in ITHit.WebDAV.Server.dll) Version: 13.3.13068
Syntax
public interface IUploadProgress : IResumableUploadBase

The IUploadProgress type exposes the following members.

Methods
  NameDescription
Public methodCode exampleGetUploadProgressAsync
Gets IEnumerable with items that are being uploaded to this item subtree.
Top
Remarks

This interface should be implemented on files that can provide upload progress information to client application. Optionally it can be implemented on folder items.

When implementing this interface you may need to configure PutUploadProgressAndResumeModule and PostUploadProgressModule module in your web.config file if your WebDAV server is hosted in IIS/ASP.NET.

Usually client application requests upload progress in following cases:

  • If connection was broken (paused) and client would like to restore upload. Client will submit upload-progress request to get number of bytes successfully saved on server side and will start the upload from the next byte. You must add PutUploadProgressAndResumeModule in your web.config to support this scenario if your application is running ASP.NET 2.0 pool. The PutUploadProgressAndResumeModule" is not required if you are using ASP.NET 4.0 pool and is ignored if you include it in web.config
  • When client application requires information about how much of the uploaded file was processed on server side. Usually this is required by Microsoft Internet Explorer 9 and earlier only. IE 9 and earlier does not have any information about how much of the file was submitted to server. It will submit upload-progress request to update its upload progress bar from time to time. You must add PostUploadProgressModule in your web.config to support this scenario.

To check if folder or file supports upload-progress report and resumable upload feature the client application will submit OPTIONS request to that item. If the item implements IUploadProgress interface Engine will add 'resumable-upload' token to DAV response header. See example below.

To get information about file upload progress client will submit REPORT request to that file with upload progress type. The Engine will call GetUploadProgressAsync method in this case. You will return an IEnumerableT that contains single item (this file implementing IResumableUpload) from GetUploadProgressAsync method implementation. The engine will extract necessary info from the returned IResumableUpload interface and return it to client. The response will contain XML with information about upload progress for the requested file: url of the file, number or bytes uploaded, total size of the file and time when last save operation occurred.

The response returned by server Engine to client is a REPORT multistatus response that contains three properties for each file:

  • ithit:bytes-uploaded - integer value. Number of bytes uploaded and saved in persistent storage. If upload was broken or paused the client application will usually start upload from the next byte returned in this property.
  • ithit:last-chunk-saved - date\timein in RFC 1123 format. Indicates when last chunk was saved. May be used in admin applications and automatic maintenance tools to remove files that were not fully uploaded.
  • ithit:total-content-length - integer value. Total file size that is being uploaded to server. Thin client applications may use this value for displaying upload progress.

See example of upload progress report below.

The client application can also submit upload-progress REPORT request to a folder. In this case from your GetUploadProgressAsync property implementation you will return IEnumerable containing files that are being uploaded that reside in the folder's subtree. The response XML will contain info about each file from the IEnumerableT in a separate response tag. See example below.

If item does not support upload-progress report and server is based on IT Hit WebDAV Server Engine the server will respond with '403 Forbidden' to REPORT request. The body will contain <A:supported-report xmlns="DAV:"/> element. If server does not support REPORT verb you will get 405 Method Not Allowed response.

Examples

OPTIONS request is used to determine if folder or file supports resumable upload.

Request:

OPTIONS /Folder/ HTTP/1.1
Host: davserver
Content-Length: 0
Response:
HTTP/1.1 200 OK
Content-Length: 0
Accept-Ranges: none
DAV: 1, 2, resumable-upload
Public: OPTIONS, PROPFIND, PROPPATCH, COPY, MOVE, DELETE, MKCOL, LOCK, UNLOCK
Allow: OPTIONS, PROPFIND, PROPPATCH, COPY, MOVE, DELETE, MKCOL, LOCK, UNLOCK

Upload progress report submitted over file contains info about single item.

Request:

REPORT /LargeFile.doc HTTP/1.1
Host: http://davserver/
Content-Type: application/xml; charset=\"utf-8\"
Content-length: 32

<upload-progress xmlns='ithit'/>
Response:
 HTTP/1.1 207 Multi-Status
 Content-Length: 2452
 Content-Type: application/xml;charset=UTF-8

 <?xml version="1.0" encoding="utf-8" ?>
 <D:multistatus xmlns:D="DAV:">
 <D:response>
    <D:href>http://server:8580/LargeFile.doc</D:href>
    <D:propstat>
        <D:prop>
             <ithit:bytes-uploaded>20</ithit:bytes-uploaded>
             <ithit:last-chunk-saved>Wed, 23 May 2007 13:29:43 GMT</ithit:last-chunk-saved>
             <ithit:total-content-length>150742</ithit:total-content-length>    
       </D:prop>
       <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>        
 </D:response>        
</D:multistatus>

Upload progress report submitted over folder contains info about all files being uploaded to subtree.

Request:

REPORT /folder HTTP/1.1
Host: http://server:8580/
Content-Type: application/xml; charset=\"utf-8\"
Content-length: 32

<upload-progress xmlns='ithit'/>
Response:
 HTTP/1.1 207 Multi-Status
 Content-Length: 2452
 Content-Type: application/xml;charset=UTF-8

 <?xml version="1.0" encoding="utf-8" ?>
 <D:multistatus xmlns:D="DAV:" xmlns:ithit="ithit">
 <D:response>
    <D:href>http://server:8580/folder/LargeFile.doc</D:href>
    <D:propstat>
        <D:prop>
             <ithit:bytes-uploaded>20</ithit:bytes-uploaded>
             <ithit:last-chunk-saved>Wed, 23 May 2007 13:29:43 GMT</ithit:last-chunk-saved>
             <ithit:total-content-length>150742</ithit:total-content-length>
       </D:prop>
       <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
 </D:response>
 <D:response>
    <D:href>http://server:8580/folder/nestedfolder/AnotherLargeFile.doc</D:href>
    <D:propstat>
        <D:prop>
             <ithit:bytes-uploaded>47</ithit:bytes-uploaded>
             <ithit:last-chunk-saved>Wed, 23 May 2007 13:16:12 GMT</ithit:last-chunk-saved>
             <ithit:total-content-length>6398</ithit:total-content-length>
       </D:prop>
       <D:status>HTTP/1.1 200 OK</D:status>
    </D:propstat>
 </D:response>
</D:multistatus>

If item on server based on IT Hit WebDAV Server Engine does not support upload-progress the server will respond with 403 Forbidden response.

Request:

REPORT /LargeFile.doc HTTP/1.1
Host: http://davserver/
Content-Type: application/xml; charset=\"utf-8\"
Content-length: 32

<upload-progress xmlns='ithit'/>
Response:
HTTP/1.1 403 Forbidden
Content-Length: 31
Content-Type: application/xml;charset=UTF-8

<supported-report xmlns="DAV"/>

If server does not support REPORT verb (often non-IT Hit Engine) you will get 405 Method Not Allowed response.

Request:

REPORT /LargeFile.doc HTTP/1.1
Host: http://davserver/
Content-Type: application/xml; charset=\"utf-8\"
Content-length: 32

<upload-progress xmlns='ithit'/>
Response:
HTTP/1.1 405 Method Not Allowed
Content-Length: 0
Content-Type: application/xml;charset=UTF-8

See Also