Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Download file from document library using REST API

$
0
0

I'm trying to get file binary data.  I used below codes but it return null.  In my application, user can select files from the library for download.  I need to retrieve the binary file and then create zip file using jszip.js.

Any advise.  Thanks.


 var executor = new SP.RequestExecutor(appWebUrl);
        var url = String.format("{0}/_api/SP.AppContextSite(@target)/web/GetFileByServerRelativeUrl('{1}/{2}/{3}')/$value?@target='{4}'",
           appWebUrl, serverRelativeUrl, folderName, filename, hostWebUrl);
        executor.executeAsync({
            url: url,
            method: "GET",
            binaryStringResponseBody: true,
            success: function (data) {
               var result = data.body//this is null
            },
            error: function (err) {
                $("#error").html(JSON.stringify(err))
            }
        });



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>