def guess_file_name_stream_type_header(args):
    """
    Guess filename, file stream, file type, file header from args.

    :param args: may be string (filepath), 2-tuples (filename, fileobj), 3-tuples (filename, fileobj,
    contentype) or 4-tuples (filename, fileobj, contentype, custom_headers).
    :return: filename, file stream, file type, file header
    """
    ftype = None
    fheader = None
    if isinstance(args, (tuple, list)):
        if len(args) == 2:
            fname, fstream = args
        elif len(args) == 3:
            fname, fstream, ftype = args
        else:
            fname, fstream, ftype, fheader = args
    else:
        fname, fstream = guess_filename_stream(args)
        ftype = guess_content_type(fname)

    if isinstance(fstream, (str, bytes, bytearray)):
        fdata = fstream
    else:
        fdata = fstream.read()
    return fname, fdata, ftype, fheader
Guess filename, file stream, file type, file header from args.

    :param args: may be string (filepath), 2-tuples (filename, fileobj), 3-tuples (filename, fileobj,
    contentype) or 4-tuples (filename, fileobj, contentype, custom_headers).
    :return: filename, file stream, file type, file header