I'm trying to read a file, create a "FileContainer", and a DataUrl from a fileReader so i can send it to a web api.
My problem is that the Api call fires before my object is created, so i send Null to the api. which means that if i send a small file, it works.
My code for the reader look something like this
var reader = new FileReader();
reader.onload = (function (theFile) {
    return function (e) {
        var newFile = {
            name: theFile.name,
            type: theFile.type,
            size: theFile.size,
            lastModifiedDate: theFile.lastModifiedDate
        }
        var binaryString = e.target.result;
        updloadedFile(newFile, binaryString, selectedFolder, scope, fileProgrss);
        }
    };
})(f);
reader.readAsDataURL(f)
And for my http.post call
function updloadedFile(file, data, selectedFolder, scope, fileProgrss) {
    var dummyobj = {
        Name: file.name,
        Extension: file.name.split('.')[0],
        Path: selectedFolder.Path,
        DataString: data,
    }
    $http.post('/api/Files/Upload/',
      JSON.stringify(dummyobj),
      {
          headers: {
              'Content-Type': 'application/json'
          }
      }
  ).success(function (data2) {
  }).error(function (data, status, headers, config) {
  });
}
 
     
     
     
     
    