async def __get_file_client(directory_client: DataLakeDirectoryClient, path): file_client: DataLakeFileClient = directory_client.get_file_client(path) try: await file_client.get_file_properties() except ResourceNotFoundError: # We return None to indicate that the file doesnt exist. return None except HttpResponseError as error: message = f'({type(error).__name__}) Problems checking if file exist: {error}' raise HTTPException(status_code=error.status_code, detail=message) from error return file_client
async def download_file( filename: str, directory_client: DataLakeDirectoryClient) -> StorageStreamDownloader: """ Downloads file from directory_client. Args: filename (str): Filename to download from directory_client directory_client (DataLakeDirectoryClient): Client to download from. Returns: Downloaded file content """ file_client = directory_client.get_file_client(filename) try: downloaded_file = await file_client.download_file() return downloaded_file except HttpResponseError as error: message = f'({type(error).__name__}) File could not be downloaded: {error}' raise HTTPException(status_code=error.status_code, detail=message) from error