def METHOD_NAME(self, external_dir=None):
    """
    Open the smart object as binary IO.
    :param external_dir: Path to the directory of the external file.
    Example::
        with layer.smart_object.open() as f:
            data = f.read()
    """
    if self.kind == 'data':
        with io.BytesIO(self._data.data) as f:
            yield f
    elif self.kind == 'external':
        filepath = self._data.linked_file[b'fullPath'].value
        filepath = filepath.replace('\x00', '').replace('file://', '')
        if not os.path.exists(filepath):
            filepath = self._data.linked_file[b'relPath'].value
            filepath = filepath.replace('\x00', '')
            if external_dir is not None:
                filepath = os.path.join(external_dir, filepath)
        with METHOD_NAME(filepath, 'rb') as f:
            yield f
    else:
        raise NotImplementedError('alias is not supported.')