<commit_before>export default {
  getSignedURL(file, endpoint, headers) {
    let payload = {
      filePath: file.name,
      contentType: file.type
    }

    return new Promise((resolve, reject) => {
      let request = new XMLHttpRequest();
      request.open("POST", endpoint);
      request.onload = function () {
        if (request.status == 200) {
          resolve(JSON.parse(request.response));
        } else {
          reject((request.statusText));
        }
      };
      request.onerror = function (err) {
        console.error("Network Error : Could not send request to AWS (Maybe CORS errors)");
        reject(err)
      };
      Object.entries(headers).forEach(([name, value]) => {
        request.setRequestHeader(name, value);
      });
      request.send();
    });
  },
  sendFile(file, endpoint, headers) {
    var fd = new FormData();
    return this.getSignedURL(file, endpoint, headers)
      .then((response) => {
        let signature = response.signature;
        Object.keys(signature).forEach(function (key) {
          if (key == 'key') {
            fd.append('key', file.name);
          } else if (key == 'Content-Type') {
            fd.append("Content-Type", file.type);
          } else {
            fd.append(key, signature[key]);
          }
        });
        fd.append('file', file);
        return new Promise((resolve, reject) => {
          let request = new XMLHttpRequest();
          request.open('POST', response.postEndpoint);
          request.onload = function () {
            if (request.status == 201) {
              var s3Error = (new window.DOMParser()).parseFromString(request.response, "text/xml");
              var successMsg = s3Error.firstChild.children[0].innerHTML;
              resolve({
                'success': true,
                'message': successMsg<commit_msg>Use all properties, including the key, from the URL signer.<commit_after>export default {
  getSignedURL(file, endpoint, headers) {
    let payload = {
      filePath: file.name,
      contentType: file.type
    }

    return new Promise((resolve, reject) => {
      let request = new XMLHttpRequest();
      request.open("POST", endpoint);
      request.onload = function () {
        if (request.status == 200) {
          resolve(JSON.parse(request.response));
        } else {
          reject((request.statusText));
        }
      };
      request.onerror = function (err) {
        console.error("Network Error : Could not send request to AWS (Maybe CORS errors)");
        reject(err)
      };
      Object.entries(headers).forEach(([name, value]) => {
        request.setRequestHeader(name, value);
      });
      request.send();
    });
  },
  sendFile(file, endpoint, headers) {
    var fd = new FormData();
    return this.getSignedURL(file, endpoint, headers)
      .then((response) => {
        let signature = response.signature;
        Object.keys(signature).forEach(function (key) {
          fd.append(key, signature[key]);
        });
        fd.append('file', file);
        return new Promise((resolve, reject) => {
          let request = new XMLHttpRequest();
          request.open('POST', response.postEndpoint);
          request.onload = function () {
            if (request.status == 201) {
              var s3Error = (new window.DOMParser()).parseFromString(request.response, "text/xml");
              var successMsg = s3Error.firstChild.children[0].innerHTML;
              resolve({
                'success': true,
                'message': successMsg
{'fraction_non_alphanumeric': 0.1367497168742922, 'fraction_numerical': 0.005096262740656852, 'mean_word_length': 2.151650312221231, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '631973', 'n_tokens_mistral': 967, 'n_tokens_neox': 946, 'n_words': 216}