<commit_before>angular.module(PKG.name + '.services')
  .factory('myFileUploader', function($q, $window, cfpLoadingBar) {
    function upload(fileObj){
      var deferred = $q.defer();
      var xhr = new $window.XMLHttpRequest();
      xhr.upload.addEventListener('progress', function (e) {
        if (e.type === 'progress') {
          console.log('App Upload in progress!');
        }
      });
      var path = fileObj.path;
      xhr.open('POST', path, true);
      xhr.setRequestHeader('Content-type', 'application/octet-stream');
      xhr.setRequestHeader('X-Archive-Name', fileObj.file.name);
      xhr.send(fileObj.file);
      cfpLoadingBar.start();
      xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) {
          if (xhr.status > 399){
            deferred.reject(xhr.response);
          } else {
            deferred.resolve();
          }
          cfpLoadingBar.complete();
        }
      };
      return deferred.promise;
    }
    return {
      upload: upload
    };
  });
<commit_msg>fix app upload on secure<commit_after>angular.module(PKG.name + '.services')
  .factory('myFileUploader', function($rootScope, $q, $window, cfpLoadingBar) {
    function upload(fileObj){
      var deferred = $q.defer();

      if (!$rootScope.currentUser || !$rootScope.currentUser.token) {
        deferred.reject(400);
      }

      var xhr = new $window.XMLHttpRequest();
      xhr.upload.addEventListener('progress', function (e) {
        if (e.type === 'progress') {
          console.log('App Upload in progress!');
        }
      });
      var path = fileObj.path;
      xhr.open('POST', path, true);
      xhr.setRequestHeader('Content-type', 'application/octet-stream');
      xhr.setRequestHeader('X-Archive-Name', fileObj.file.name);
      xhr.setRequestHeader('X-ApiKey', '');
      xhr.setRequestHeader('Authorization', 'Bearer ' + $rootScope.currentUser.token);
      xhr.send(fileObj.file);
      cfpLoadingBar.start();
      xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) {
          if (xhr.status > 399){
            deferred.reject(xhr.response);
          } else {
            deferred.resolve();
          }
          cfpLoadingBar.complete();
        }
      };
      return deferred.promise;
    }
    return {
      upload: upload
    };
  });

{'fraction_non_alphanumeric': 0.151931330472103, 'fraction_numerical': 0.004721030042918455, 'mean_word_length': 2.3063829787234043, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6584696', 'n_tokens_mistral': 734, 'n_tokens_neox': 714, 'n_words': 121}