<commit_before>'use strict';

const fs = require('fs');
const path = require('path');

// uploadObject (task: Task, fileName: String) => Promise
function uploadObject (task, fileName) {
  const cwd = task.cwd;
  let stream = fs.createReadStream(path.join(cwd, fileName));
  task.emit('uploading', fileName);

  // lookup details in our local files Map
  let meta;
  try {
    meta = task.files.get(fileName);
  } catch (err) {
    const error = new Error('metadata for ' + fileName + ' unavailable');
    task.emit('error', error, fileName);
    return Promise.reject(error);
  }

  // make request to AWS S3
  return new Promise((resolve, reject) => {
    task.s3.upload({
      Body: stream,
      ContentType: meta.ContentType,
      Key: fileName
    }, (err, data) => {
      if (err) {
        reject(err);
        return;
      }
      resolve(data);
    });
  })
    .then(() => {
      task.emit('uploaded', fileName);
    })
    .catch((err) => {
      task.emit('error', err, fileName);
      throw err;
    });
}

module.exports = {
  uploadObject,

  // uploadObjects (task: Task, fileList: String[]) => Promise
  uploadObjects (task, fileList) {
    return Promise.all(fileList.map((fileName) => uploadObject(task, fileName)));
  }
};<commit_msg>feature(upload): add acl<commit_after>'use strict';

const fs = require('fs');
const path = require('path');

// uploadObject (task: Task, fileName: String) => Promise
function uploadObject (task, fileName) {
  const cwd = task.cwd;
  let stream = fs.createReadStream(path.join(cwd, fileName));
  task.emit('uploading', fileName);

  // lookup details in our local files Map
  let meta;
  try {
    meta = task.files.get(fileName);
  } catch (err) {
    const error = new Error('metadata for ' + fileName + ' unavailable');
    task.emit('error', error, fileName);
    return Promise.reject(error);
  }

  // make request to AWS S3
  return new Promise((resolve, reject) => {
    task.s3.upload({
      Body: stream,
      ContentType: meta.ContentType,
      Key: fileName,
      ACL: task.ACL
    }, (err, data) => {
      if (err) {
        reject(err);
        return;
      }
      resolve(data);
    });
  })
    .then(() => {
      task.emit('uploaded', fileName);
    })
    .catch((err) => {
      task.emit('error', err, fileName);
      throw err;
    });
}

module.exports = {
  uploadObject,

  // uploadObjects (task: Task, fileList: String[]) => Promise
  uploadObjects (task, fileList) {
    return Promise.all(fileList.map((fileName) => uploadObject(task, fileName)));
  }
};
{'fraction_non_alphanumeric': 0.16065830721003135, 'fraction_numerical': 0.001567398119122257, 'mean_word_length': 2.8917682926829267, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '2840782', 'n_tokens_mistral': 801, 'n_tokens_neox': 816, 'n_words': 204}