2

I want to read this png in binary format.

I have been reading all over the net, and this looks like the correct way of doing it with angular.

But it just does not work. Any idea why?

 $http({
                url: 'somepng.png',
                method: 'GET',
                data: '',
                responseType: 'arraybuffer'
            }).success(function(resp, config1, config2, config3) {
                console.log(typeof resp); // this is a string, weird! in Chrome
                console.log(resp);
            });

The arrray buffer returns a string instead of an array o of bytes.

3
  • 1
    Try to take a look at stackoverflow.com/questions/16791295/… Commented Dec 12, 2014 at 16:25
  • Whisher, this uses the example exactly like in the post you gave me. Commented Dec 12, 2014 at 17:19
  • Adding the responseType: "arraybuffer" to the config worked for me, as proposed in the answer linked to by @Whisher. Commented Nov 9, 2015 at 9:45

1 Answer 1

1
var config = {headers: {
            'Accept': "image/png"
        }
    };
$http.get('somepng.png', config).success(successCallback).error(errorCallback);

this answer is the changed one....

Sign up to request clarification or add additional context in comments.

2 Comments

I am not doing post request
That didn't change anything for me and it doesn't seem logical why it should.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.