'Writes data from a stream'

def write_from_stream(self, dataset, stream):

    fd = open(dataset.file_name, 'wb')
    while True:
        chunk = stream.read(1048576)
        if (not chunk):
            break
        os.write(fd, chunk)
    os.close(fd)
