M-Files API 22.6.11519.0
DownloadFileAsDataURI Method
VaultObjectFileOperations Object : DownloadFileAsDataURI Method
The object version.
The file ID.
The file version.
Downloads the content of the specified file as a data URI.
Visual Basic
Public Function DownloadFileAsDataURI( _
   ByVal ObjVer As ObjVer, _
   ByVal File As Long, _
   ByVal FileVersion As Long _
) As String
The object version.
The file ID.
The file version.

The data URI scheme is a URI scheme that encodes content within the URI itself. This is especially useful within the M-Files UI Extensibility Framework. In this context, the data URIs provide a convenient method for displaying, for instance, small images located in the vault in dashboard content.

Only base64-encoded data URIs are supported and MIME-type is not optional. Downloading files larger than 64MB is not supported because the whole data is be kept in the memory of the calling process.

For more information, search MSDN for "data uri".

This example is directly applicable in Internet Explorer browsers only. The sample vault needs to have the name Sample Vault in M-Files Client Settings. The Javascript file needs to be named download.js.
// Connect to Sample Vault using M-Files Client.
var mfilesClient = new ActiveXObject( "MFilesAPI.MFilesClientApplication" );
var vault = mfilesClient.BindToVault( "Sample Vault", 0, true, false );    

// Add event handler which downloads an image from the Sample Vault and displays it in an image tag.
addEventHandler( window, "load", function() {
    // Create MFilesAPI.ObjVer object which represents Arch.jpg in Sample Vault.
    var archJpgObjVer = new ActiveXObject( "MFilesAPI.ObjVer" );
    archJpgObjVer.Type = 0;
    archJpgObjVer.ID = 326;        
    archJpgObjVer.Version = 5;
    // Get information about that object in the vault.
    var archJpg = vault.ObjectOperations.GetObjectVersionAndProperties( archJpgObjVer, false );
    var archJpgFile = archJpg.VersionData.Files.Item( 1 );
     // Download the Arch.jpg as a data URI.
    var archAsDataUri = vault.ObjectFileOperations.DownloadFileAsDataURI( archJpg.ObjVer, archJpgFile.ID, archJpgFile.Version );
    // Set the data URI to an image tag within the HTML page.
    var image = document.getElementById( "arch" );
    image.src = archAsDataUri;        
} );

* Adds specified event handler to the element.
function addEventHandler( element, evt, handler ) {
    if( element.addEventListener) {
        // W3C method
        element.addEventListener( evt, handler, false );
    } else if( element.attachEvent) {
        // Old IE method.
        element.attachEvent( "on"+evt, handler );
    } else {
        // Legacy method.
        element["on"+evt] = handler;
<!DOCTYPE html>
    <title>Arch.jpg Display</title>    
    <script type="text/javascript" src="download.js"></script>
        #arch {
          height: 250px;
          width: 250px;          
    <h1 align=center>File Download Demo</h1> 
    <img id="arch" />    
See Also

VaultObjectFileOperations Object  | VaultObjectFileOperations Members