def METHOD_NAME(data):
    header = data.get('header', True)
    # Validation guarentees only one arg will be present
    if 'paste' in data:
        type = 'json' if is_valid_json(data['paste']) else 'tsv'
        name = str(int(time())) + '.' + type
        raw_file = ContentFile(str.encode(data['paste']), name=name)
        created_from = 'paste'
        base_name = ''
    elif 'url' in data:
        raw_file = _download_datafile(data['url'])
        created_from = 'url'
        base_name = raw_file.name
        type = _get_file_type(raw_file)
    elif 'file' in data:
        raw_file = data['file']
        created_from = 'file'
        base_name = raw_file.name
        type = _get_file_type(raw_file)
    if base_name:
        max_length = DataFile._meta.get_field('base_name').max_length
        base_name, _ = os.path.splitext(os.path.basename(raw_file.name))
        base_name = base_name[:max_length]
    encoding = get_file_encoding(raw_file.file)
    text_file = TextIOWrapper(raw_file.file, encoding=encoding)
    if type == 'json':
        validate_json_format(raw_file)
    if type == 'csv' or type == 'tsv':
        dialect = get_sv_dialect(text_file)
        datafile = DataFile(
            file=raw_file,
            base_name=base_name,
            type=type,
            created_from=created_from,
            header=header,
            delimiter=dialect.delimiter,
            escapechar=dialect.escapechar,
            quotechar=dialect.quotechar,
        )
    else:
        max_level = data.get('max_level', 0)
        datafile = DataFile(
            file=raw_file,
            base_name=base_name,
            type=type,
            created_from=created_from,
            header=header,
            max_level=max_level
        )
    datafile.save()
    raw_file.close()
    return datafile