vendredi 26 mai 2017

Download image from angular js

I am getting image from the MongoDB . Now i want to download the image to my system through code.

From this code i am getting the object : $scope.clickEvent = function(x) {

             var path = x.path.replace('uploads','');
             $http({
             method: 'GET',
                    url: $API_URL + path,
                    headers: {
                        "Authorization": $localStorage.currentUser.token
                    }
                }).then(function (response) {



                 var file = new Blob([response.data], {type: 'application/Image'});
                    var fileURL = URL.createObjectURL(file);
                    window.open(fileURL);

                    console.log("Result: " + response.data);


                });
            };

Bt the thing i am getting download is: enter image description here




Aucun commentaire:

Enregistrer un commentaire