def save_upload(uploaded, filename, raw_data):
    try:
        from io import FileIO, BufferedWriter

        with BufferedWriter(FileIO(filename, "wb")) as dest:
            # if the "advanced" upload, read directly from the HTTP request
            # with the Django 1.3 functionality
            if raw_data:
                if isinstance(uploaded, basestring):
                    dest.write(uploaded)
                else:
                    foo = uploaded.read(1024)
                    while foo:
                        dest.write(foo)
                        foo = uploaded.read(1024)
            # if not raw, it was a form upload so read in the normal Django
            # chunks fashion
            else:
                for c in uploaded.chunks():
                    dest.write(c)
                    # got through saving the upload, report success
            return True
    except IOError:
        # could not open the file most likely
        pass
    return False
raw_data: if True, uploaded is an HttpRequest object with the file being
dataset/ETHPy150Open treeio/treeio/treeio/core/views.py/save_upload