I have a bunch of image urls and I want to download the images from the browser into a zip file. I'm planning on using jszip to create the zip file. And I have all the image urls from the server. What I attempted was :
var img = zip.folder("profiles");
async.mapSeries($scope.queriedUsers,
function (user, iterCallback) {
delete $http.defaults.headers.common['X-Requested-With'];
$http.get(user.profile_image_url, {responseType: "arraybuffer"})
.success(function (data) {
iterCallback(null, {data: data, name: user.screen_name});
})
.error(function (data, status) {
iterCallback(status, data);
})
},
function (err, results) {
_.each(results, function (result){
img.file(result.screen_name + ".gif", result.data, {base64: true});
});
var content = zip.generate();
window.location.href = "data:application/zip;base64," + content;
});
And the error i got was:
OPTIONS <url> No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
What I find interesting is that in the html the images load fine:
<tbody>
<tr ng-repeat="user in queriedUsers">
<td><a href="https://twitter.com/{{user.screen_name}}"><img ng-src="{{user.profile_image_url}}" alt="User Twitter Image"></a></td>
<td><a href="https://twitter.com/{{user.screen_name}}">{{user.screen_name}}</a></td>
<td>{{user.name}}</td>
<td>{{user.description}}</td>
</tr>
</tbody>
How do I load the image data into angularjs? Is there a way to get it directly for the ng-src?
Thanks