Get return from angular-file-upload

1

I'm using the angular file upload , it works great, but I need the feedback that the server me available. I'm using the following code:

  $scope.uploader = new FileUploader({
    url: 'https://api.imgur.com/3/image',
    alias: 'image',
    headers: {
        Authorization: 'Client-ID XXXXXXXXXXXXXXXXXXXX',
    },
    autoUpload: true,
  });

The answer:

{"data":{"id":"sK1PnoE","title":null,"description":null,"datetime":1454191817,"type":"image\/png","animated":false,"width":400,"height":400,"size":8981,"views":0,"bandwidth":0,"vote":null,"favorite":false,"nsfw":null,"section":null,"account_url":null,"account_id":0,"comment_preview":null,"deletehash":"LLLGwJ7PdzYsord","name":"","link":"http:\/\/i.imgur.com\/sK1PnoE.png"},"success":true,"status":200}

Edited ---

I can not access CallBacks methods, I tried the following ways:

$scope.uploader.onCompleteItem = function(fileItem, response, status,headers) {
      console.log(response);
  };

  $scope.uploader = new FileUploader({
    //xxxxx
  }).onSuccessItem = function(fileItem, response, status,headers) {
    console.log(response);
  };
    
asked by anonymous 30.01.2016 / 23:13

1 answer

2

Response data of fileUploader is received within plugin functions, whether for success, error, progress, or other methods.

See%% functions on this page: link

Example:

$scope.uploader.onSuccessItem = function(fileItem, response, status,headers) {
    //sua função aqui...
};

So you just have to check callback or response , for example, to check. Since there is status for each step, to identify an error, you should use callback callback , to progress use onErrorItem , and so on.

    
30.01.2016 / 23:37