<commit_before>// Dependencies
var http = require('./util/http.js').func;
var promise = require('./util/promise.js');

// Args
exports.args = ['data', 'itemOptions', 'asset', 'jar'];

// Define
function upload (jar, data, itemOptions, asset) {
  return function (resolve, reject) {
    var httpOpt = {
      url: 'https://data.roblox.com/Data/Upload.ashx?assetid=' + (asset || 0),
      options: {
        resolveWithFullResponse: true,
        method: 'POST',
        jar: jar,
        body: data,
        headers: {
          'Content-Type': 'application/xml'
        }
      }
    };
    if (itemOptions) {
      httpOpt.url += '&type=Model&genreTypeId=1&name=' +
        itemOptions.name +
        '&description=' +
        (itemOptions.description || '') +
        '&ispublic=' +
        itemOptions.locked +
        '&allowComments=' +
        itemOptions.allowComments +
        '&groupId=' +
        (itemOptions.groupId || '');
    }
    http(httpOpt)
    .then(function (res) {
      if (res.statusCode === 200) {
        resolve();
      } else {
        reject(new Error('Upload failed, confirm that all item options, asset options, and upload data are valid.'));
      }
    });
  };
}

exports.func = function (args) {
  return promise(upload(args.jar, args.data, args.itemOptions, args.asset));
};<commit_msg>Add<commit_after>// Dependencies
var http = require('./util/http.js').func;
var promise = require('./util/promise.js');

// Args
exports.args = ['data', 'itemOptions', 'asset', 'jar'];

// Define
function upload (jar, data, itemOptions, asset, type) {
  return function (resolve, reject) {
    var httpOpt = {
      url: 'https://data.roblox.com/Data/Upload.ashx?assetid=' + (asset || 0),
      options: {
        resolveWithFullResponse: true,
        method: 'POST',
        jar: jar,
        body: data,
        headers: {
          'Content-Type': 'application/xml'
        }
      }
    };
    if (itemOptions) {
      httpOpt.url += '&type=' + (type || 'Model') + '&genreTypeId=1&name=' +
        itemOptions.name +
        '&description=' +
        (itemOptions.description || '') +
        '&ispublic=' +
        !itemOptions.copyLocked +
        '&allowComments=' +
        itemOptions.allowComments +
        '&groupId=' +
        (itemOptions.groupId || '');
    } else if (!asset) {
      reject(new Error('ItemOptions is required for new assets.'));
      return;
    }
    http(httpOpt)
    .then(function (res) {
      if (res.statusCode === 200) {
        resolve(res.body);
      } else {
        reject(new Error('Upload failed, confirm that all item options, asset options, and upload data are valid.'));
      }
    });
  };
}

exports.func = function (args) {
  return promise(upload(args.jar, args.data, args.itemOptions, args.asset, args.type));
};
{'fraction_non_alphanumeric': 0.16493738819320214, 'fraction_numerical': 0.0035778175313059034, 'mean_word_length': 2.372738238841978, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1720841', 'n_tokens_mistral': 874, 'n_tokens_neox': 856, 'n_words': 190}