Download large files using REST RRS feed

  • Question

  • Previous questions on this subject point a way using RPC. This is to download files as large as 9GB. Isn't there a way to do the same in REST? Csom way of doing opening binary streams has some limits, I would expect and so looking for a way in REST.

    I was trying to download some sample file in 'chunks' from this endpoint -


    but the file was downloaded fully not in chunks. Is it that Sharepoint Online doesn't support "Range" to supply the byte range am looking for? Please help.

    Saturday, March 18, 2017 12:47 PM

All replies

  • Hi,

    It is seems not supported to use chunk download file using REST API from SharePoint Online , here is a similar thread for your reference:

    As you said, we can use RPC to achieve it.

    string fullFilePath = String.Empty;
    Uri targetSite = new Uri(ctx.Web.Url);
    SharePointOnlineCredentials spCredentials = (SharePointOnlineCredentials)ctx.Credentials;
    string authCookieValue = spCredentials.GetAuthenticationCookie(targetSite);
    string requestUrl = ctx.Url + "/_vti_bin/_vti_aut/author.dll";
    string method = Utility.GetEncodedString("get document:");
    serviceName = Utility.GetEncodedString(ctx.Web.ServerRelativeUrl);
        documentName = documentName.Substring(1);
    documentName = Utility.GetEncodedString(documentName);
    string oldThemeHtml = "false";
    string force = "true";
    string getOption = "none";
    string docVersion = String.Empty; //directly passed as empty
    string timeOut = "0";
    string expandWebPartPages = "true";
    string rpcCallString = String.Format("method={0}&service%5fname={1}&document%5fname={2}&old%5ftheme%5fhtml={3}&force={4}&get%5foption={5}&doc%5fversion=&timeout={6}&expandWebPartPages={7}",
        method, serviceName, documentName, oldThemeHtml, force, getOption, timeOut, expandWebPartPages);
    HttpWebRequest wReq = WebRequest.Create(requestUrl) as HttpWebRequest;
    wReq.Method = "POST";
    wReq.ContentType = "application/x-vermeer-urlencoded";
    wReq.Headers["X-Vermeer-Content-Type"] = "application/x-vermeer-urlencoded";
    wReq.UserAgent = "MSFrontPage/15.0";
    wReq.UseDefaultCredentials = false;
    wReq.Accept = "auth/sicily";
    wReq.Headers["MIME-Version"] = "1.0";
    wReq.Headers["X-FORMS_BASED_AUTH_ACCEPTED"] = "T";
    wReq.Headers["Accept-encoding"] = "gzip, deflate";
    wReq.Headers["Cache-Control"] = "no-cache";
    wReq.CookieContainer = new CookieContainer();
        new Cookie("SPOIDCRL",
    wReq.KeepAlive = true;
    //create unique dir for the download
    DirectoryInfo tempFilePath = Directory.CreateDirectory(Path.Combine(tempFileLoc, Guid.NewGuid().ToString()));
    using (Stream requestStream = wReq.GetRequestStream())
        byte[] rpcHeader = Encoding.UTF8.GetBytes(rpcCallString);
        requestStream.Write(rpcHeader, 0, rpcHeader.Length);
        fullFilePath = Path.Combine(tempFilePath.FullName, fileName);
        using (Stream strOut = File.OpenWrite(fullFilePath))
            using (var sr = wReq.GetResponse().GetResponseStream())
                byte[] buffer = new byte[16 * 1024];
                int read;
                bool isHtmlRemoved = false;
                while ((read = sr.Read(buffer, 0, buffer.Length)) > 0)
                        string result = Encoding.UTF8.GetString(buffer);
                        int startPos =result.IndexOf("</html>");
                        if(startPos >-1)
                            //get the length of the text, '</html>' as well
                            startPos += 8;
                            strOut.Write(buffer, startPos, read - startPos);
                            isHtmlRemoved = true;
                        strOut.Write(buffer, 0, read);

    Best Regards,


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact

    Monday, March 20, 2017 6:58 AM