The contents of a single file.



Output: Stream: application/octet-stream
  Retrieves the object file contents.
Parameters: ?X-Hmac- Specifies the HMAC key
  ?mac - If true, appends a SHA-512 message authentication code at the end of the stream.
  ?format (optional, defaulting to native if not provided)

The format querystring parameter can be one of the following values:

  • native (default) - Downloads the file in its native/current/stored format (supported in M-Files 11.0.4090.0 and higher).
  • pdf - Converts the file to a PDF and downloads it (supported in M-Files 11.0.4090.0 and higher).
  • displaypdfonly - Converts the file to a display-only PDF with printing and copying disabled (supported in M-Files 20.1.8669.0 and higher).

Note: larger files may not be able to be converted to PDF, depending upon the server configuration.


Note that PUT and DELETE verbs may not be supported in IIS; it is recommended to route them via the POST verb and specify the _method querystring parameter, as detailed in the compatibility page.

Input: Stream: application/octet-stream or multipart/form-data
Output: ObjectVersion
  Replaces the object file contents.

Supports Range header on GET:


public string DownloadFile( int type, int id, int version, int fileid )
    // Construct the URL by filling type, id, version and file id.
    string url = string.Format(
        type, id, version, fileid );

    // Create the web request.
    WebRequest request = WebRequest.Create( url );

    // Fill the authentication information.
    request.Headers["X-Authentication"] = this.AuthenticationToken;

    // Receive the response.
    var response = request.GetResponse();

    return new StreamReader( response.GetResponseStream() ).ReadToEnd();
Example 1: Downloading a file.