@classmethod
def _mark_image_file_stored(cls, mapper, connection, target):
    """When the session flushes, stores actual image files into
        the storage.  Note that these files could be deleted back
        if the ongoing transaction has done rollback.  See also
        :meth:`_delete_image_file()`.

        """
    try:
        file_ = target.file
    except AttributeError:
        raise TypeError(
            'sqlalchemy_imageattach.entity.Image which is to be inserted must have file to store'
            )
    try:
        try:
            store = target.store
        except AttributeError:
            raise TypeError(
                'sqlalchemy_imageattach.entity.Image which is to be inserted must have store for the file'
                )
        store.store(target, file_)
        cls._stored_images.add((target, store))
        del target.file, target.store
    finally:
        file_.close()
