def _load_documents_with_metadata(
        self,
        payloads: List[_OneDriveResourcePayload],
        directory: str,
        recursive: bool = True,
    ) -> List[Document]:
        """
        Load documents from a specified directory using the SimpleDirectoryReader
        and associate them with their respective metadata.

        Parameters
        ----------
        - payloads (List[_OneDriveResourcePayload]): List of payloads containing metadata and downloaded file paths.
        - directory (str): The directory from which to load the documents.
        - recursive (bool, optional): Whether to perform a recursive search through the directory. Defaults to True.

        Returns
        -------
        - List[Document]: Loaded documents from the specified directory with associated metadata.

        """
        file_name_to_metadata = {
            payload.downloaded_file_path: payload.resource_info for payload in payloads
        }

        def get_metadata(filename: str) -> Any:
            return file_name_to_metadata[filename]

        simple_loader = SimpleDirectoryReader(
            directory,
            file_extractor=self.file_extractor,
            required_exts=self.required_exts,
            file_metadata=get_metadata,
            recursive=recursive,
        )
        return simple_loader.load_data()

        Load documents from a specified directory using the SimpleDirectoryReader
        and associate them with their respective metadata.

        Parameters
        ----------
        - payloads (List[_OneDriveResourcePayload]): List of payloads containing metadata and downloaded file paths.
        - directory (str): The directory from which to load the documents.
        - recursive (bool, optional): Whether to perform a recursive search through the directory. Defaults to True.

        Returns
        -------
        - List[Document]: Loaded documents from the specified directory with associated metadata.

        
llama-index-integrations/readers/llama-index-readers-microsoft-onedrive/llama_index/readers/microsoft_onedrive/base.py