I am trying to get a document from document library.I am getting the file but I can't get its binary value.

    url: fileUrl,
    binaryStringResponseBody: true,
    headers: {
        "Accept": "application/json; odata=verbose",
        "X-RequestDigest": 'digest'
    type: "GET"
.done(Function.createDelegate(this, readFileSuccess))
.error(Function.createDelegate(this, readFileFailure));

but it didn't give me a binary value for the file. I need to get binary value and store it to local storage ( Web SQL ).

How to get the binary value?

  • Is FileURL direct link of file or is it a REST query? Commented Apr 14, 2015 at 16:42
  • i am using direct link
    – user36977
    Commented Apr 14, 2015 at 16:57

1 Answer 1


You can use success handler for reading file content

function readFileSuccess(data) {


var executor = new SP.RequestExecutor(weburl);
var info = {
    url: fileContentUrl,
    method: "GET",
    binaryStringResponseBody: true,
    success: function (data) {
        //binary data available in data.body
        var result = data.body;
    error: function (err) {
  • yes i have used that but it doesnt give me a binary data
    – user36977
    Commented Apr 14, 2015 at 16:48
  • You should use SP.RequestExecutor to read in binary format. Take a look at this link techmikael.blogspot.no/2013/07/… Commented Apr 14, 2015 at 16:51
  • its also give me same result
    – user36977
    Commented Apr 14, 2015 at 16:56
  • You can convert it to binary using jsfiddle.net/bdgNZ/2 Commented Apr 14, 2015 at 17:07
  • both binary are different.. if i convert that data to binary and if i get binary value from server side code. document is corrupted after converting that
    – user36977
    Commented Apr 14, 2015 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.