'Initializes the current instance from an Aff4Stream.
Args:
file_obj: An Aff4Stream representing a file.
with_details: True if all details of the Aff4Object should be included,
false otherwise.
Returns:
A reference to the current instance.'

def InitFromAff4Object(self, file_obj, with_details=False):

    self.name = file_obj.urn.Basename()
    self.path = '/'.join(file_obj.urn.Path().split('/')[2:])
    self.is_directory = ('Container' in file_obj.behaviours)
    self.hash = file_obj.Get(file_obj.Schema.HASH, None)
    stat = file_obj.Get(file_obj.Schema.STAT)
    if stat:
        self.stat = stat
    if (not self.is_directory):
        try:
            self.last_collected = file_obj.GetContentAge()
        except AttributeError:
            logging.debug("File-like    object    %s    doesn't    have    GetContentAge    defined.", file_obj.__class__.__name__)
        if self.last_collected:
            self.last_collected_size = file_obj.Get(file_obj.Schema.SIZE)
    type_obj = file_obj.Get(file_obj.Schema.TYPE)
    if (type_obj is not None):
        self.type = type_obj
        self.age = type_obj.age
    if with_details:
        self.details = ApiAff4ObjectRepresentation().InitFromAff4Object(file_obj)
    return self
