Windows Dev Center

Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

WL.download (web)

Last modified: March 13, 2015

Makes a call to download a file from Microsoft OneDrive.

Important note Important

WL.download is supported only for use with web apps. If you are writing a Windows Store app using JavaScript, use WL.backgroundDownload instead.

Parameters

  • properties

    Required. A JSON object that contains the following properties, which are necessary to make the REST API call:

    Name

    Type

    Description

    Default Value

    path

    string

    Required. The path to the file to download. For information on specifying paths for REST objects, see REST reference.

    None

  • callback

    Specifies a callback function that is executed when the REST API call is complete. The callback function takes the API response object as a parameter. The response object exposes the data that is returned from the Live SDK, or, if an error occurs, an error property that contains the error code.

    Note Note

    Although the callback parameter is still supported, we recommend that you use the Promise object instead, which is described later in this topic.

Return value

Returns a Promise object. This object's then method provides the onError parameter to enable your code to handle a failed call to the corresponding WL.download method.

Example

<button onclick="downloadFile()">Open file directly (calling WL.download)</button>
function downloadFile() {
    WL.login({
        scope: "wl.skydrive"
    }).then(
        function (response) {
            WL.download({
                path: "file.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!131/content"
            }).then(
                function (response) {
                    // Will not be called for web apps.
                },
                function (responseFailed) {
                    document.getElementById("info").innerText =
                        "Error downloading file: " + responseFailed.error.message;
                }
            );
        },
        function (responseFailed) {
            document.getElementById("info").innerText =
                "Error signing in: " + responseFailed.error.message;
        }
    );
}

Requirements

Library

Wl.js

Show:
© 2015 Microsoft