I want to download a file using REST API.

I have a file in a document library /folder. I want download that file, but with a different name. 

Edit 1 : Below is my code. i am able to download file on Chrome browser but data gets corrupted and also not working on IE 10+. 

```
function SaveToDisk_blob(blobURL, fileName)
{
var reader = new FileReader();
console.log(blobURL.body)
console.log(fileName.split(".")[1])
var blob = new Blob([blobURL.body], { type: "application/"+fileName.split(".")[1]+"" });
reader.readAsDataURL(blob);
reader.onload = function (event) {
    var save = document.createElement('a');
    save.href = event.target.result;
    save.target = '_blank';
    save.download = fileName || 'unknown file';

    var event = document.createEvent('Event');
    event.initEvent('click', true, true);
    save.dispatchEvent(event);
    (window.URL || window.webkitURL).revokeObjectURL(save.href);
};
reader.onerror = function (e) {
    console.log(e)
}
}

function downloadFile(url, fileName)
{

// executes cross domain request
var appweburl = _spPageContextInfo.webAbsoluteUrl
$.getScript(appweburl + "/_layouts/15/SP.RequestExecutor.js", function () {
    var executor = new SP.RequestExecutor(appweburl);
    executor.executeAsync(
    {
        url: url,
        type: "GET",
        binaryStringResponseBody: true,
        success: function (blobURL)
        {
            SaveToDisk_blob(blobURL, fileName)
        },
        error: function (xhr)
        {
            console.log(xhr);
            console.log("downloadFile" + xhr.status + ": " + xhr.statusText);

        }
    });
});
}

```

Edit 2: i have made some more change in code.

```
function call_to_rest_binarystring(rest_url)
{
    return $.ajax({
    url: rest_url,
    method: "GET",
});
}

function downloadFile(rest_url, filepath, fileName)
{
    var dfd = $.Deferred();
if (!window.ActiveXObject) 
{
    var save = document.createElement('a');
    save.href = filepath;
    save.target = '_blank';
    save.download = fileName || 'unknown';

    var event = document.createEvent('Event');
    event.initEvent('click', true, true);
    save.dispatchEvent(event);
    (window.URL || window.webkitURL).revokeObjectURL(save.href);
    dfd.resolve(true);
}
else if (!!window.ActiveXObject && document.execCommand)
{
    var rest_return_call = call_to_rest_binarystring(rest_url)
    rest_return_call.done(function (response, status, xhr)
    {

        var blob = new Blob([response], { type: "application/" + fileName.split(".")[1] + "" });
        window.navigator.msSaveBlob(blob, fileName);

    });

}
return dfd.promise()
}

var rest_url = "<site name>/_api/web/GetFileByServerRelativeUrl('/ShareDocument/111.pdf')/openbinarystream"

downloadFile(rest_url, filepath, fileName)

```

still while we download file it is coming blank. i think i am missing something. can anyone help me with this.