Class: Version

Version Class

Namespace

ITHit.WebDAV.Client

Represents a version on a WebDAV server.

Extends

Members

ContentLengthnumber

Length of the file.

ContentTypestring

Content type of the file.

CreationDateDate

The date item was created.

DisplayNamestring

User friendly item name.

Hrefstring

This item path on the server.
List of item properties.
Current WebDAV session.

VersionNamestring

This property contains a server-defined string that is different for each version. This string is intended for display for a user.

Methods

DeleteAsync(fCallback){ITHit.WebDAV.Client.Request}

Delete version by self href.
Name Type Description
fCallback ITHit.WebDAV.Client.Version~DeleteAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.

ReadContentAsync(iBytesFrom, iBytesCount, fCallback){ITHit.WebDAV.Client.Request}

Read file content. To download only a part of a file you can specify 2 parameters in ReadContent call. First parameter is the starting byte (zero-based) at witch to start content download, the second – amount of bytes to be downloaded. The library will add Range header to the request in this case.
Name Type Description
iBytesFrom number Start position to retrieve lBytesCount number of bytes from.
iBytesCount number Number of bytes to retrieve.
fCallback ITHit.WebDAV.Client.File~ReadContentAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/myfile.txt';
var fCallback = function() {};

webDavSession.OpenFileAsync(sFolderAbsolutePath, null, function(oFileAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.File} oFile */
    var oFile = oFileAsyncResult.Result;

    oFile.GetVersionsAsync(function(oVersionsAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.Version[]} aVersions */
        var aVersions = oVersionsAsyncResult.Result;

        /** @typedef {ITHit.WebDAV.Client.Version} oVersion */
        var oVersion = aVersions[0];

        oVersion.ReadContentAsync(null, null, function(oAsyncResult) {

            /** @typedef {String} sContent */
            var sContent = oAsyncResult.Result;

            console.log('Version ' + oVersion.VersionName + ', content:' + sContent);

            fCallback(oAsyncResult);
        });
    });
});

RefreshAsync(fCallback){ITHit.WebDAV.Client.Request}

Refreshes item loading data from server.
Name Type Description
fCallback ITHit.WebDAV.Client.HierarchyItem~RefreshAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.

UpdateToThisAsync(fCallback){ITHit.WebDAV.Client.Request}

Update file to current version.
Name Type Description
fCallback ITHit.WebDAV.Client.Version~UpdateToThisVersionAsync Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.
Example
var webDavSession = new ITHit.WebDAV.Client.WebDavSession();
var sFolderAbsolutePath = 'http://localhost:87654/myfile.txt';
var fCallback = function() {};

webDavSession.OpenFileAsync(sFolderAbsolutePath, null, function(oFileAsyncResult) {

    /** @typedef {ITHit.WebDAV.Client.File} oFile */
    var oFile = oFileAsyncResult.Result;

    oFile.GetVersionsAsync(function(oAsyncResult) {

        /** @typedef {ITHit.WebDAV.Client.Version[]} aVersions */
        var aVersions = oAsyncResult.Result;

        /** @typedef {ITHit.WebDAV.Client.Version} oLastVersion */
        var oLastVersion = aVersions[aVersions.length - 1];

        oLastVersion.UpdateToThisAsync(function(oAsyncResult) {

            if (oAsyncResult.IsSuccess) {
                console.log('File `' + oFile.DisplayName + '` successfully updated to version `' + oLastVersion.VersionName + '`');
            }

            fCallback(oAsyncResult);
        });
    });
});

WriteContentAsync(sContent, sLockToken, sMimeType, fCallback){ITHit.WebDAV.Client.Request}

Writes file content.
Name Type Description
sContent string File content.
sLockToken string Lock token.
sMimeType string File mime-type.
fCallback ITHit.WebDAV.Client.File~WriteContentAsyncCallback Function to call when operation is completed.
Returns:
ITHit.WebDAV.Client.Request Request object.

Type Definitions

DeleteAsyncCallback(oResult)

Callback function to be called when version is deleted on server.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object

UpdateToThisVersionAsync(oResult)

Callback function to be called when version is updated on server.
Name Type Description
oResult ITHit.WebDAV.Client.AsyncResult Result object