async def _generate_file_entities(
        self,
        client: httpx.AsyncClient,
        task: Dict,
        task_breadcrumbs: List[Breadcrumb],
    ) -> AsyncGenerator[ChunkEntity, None]:
        """Generate file attachment entities for a task."""
        attachments_data = await self._get_with_auth(
            client, f"https://app.asana.com/api/1.0/tasks/{task['gid']}/attachments"
        )

        for attachment in attachments_data.get("data", []):
            attachment_response = await self._get_with_auth(
                client, f"https://app.asana.com/api/1.0/attachments/{attachment['gid']}"
            )

            attachment_detail = attachment_response.get("data")

            if (
                "download_url" not in attachment_detail
                or attachment_detail.get("download_url") is None
            ):
                logger.warning(
                    f"No download URL found for attachment {attachment['gid']} "
                    f"in task {task['gid']}"
                )
                continue

            # Create the file entity with metadata
            file_entity = AsanaFileEntity(
                entity_id=attachment_detail["gid"],
                breadcrumbs=task_breadcrumbs,
                file_id=attachment["gid"],
                name=attachment_detail.get("name"),
                mime_type=attachment_detail.get("mime_type"),
                size=attachment_detail.get("size"),
                total_size=attachment_detail.get("size"),  # Set total_size from API response
                download_url=attachment_detail.get("download_url"),
                created_at=attachment_detail.get("created_at"),
                modified_at=attachment_detail.get("modified_at"),
                task_gid=task["gid"],
                task_name=task["name"],
                resource_type=attachment_detail.get("resource_type"),
                host=attachment_detail.get("host"),
                parent=attachment_detail.get("parent"),
                view_url=attachment_detail.get("view_url"),
                permanent=attachment_detail.get("permanent", False),
            )

            # Different headers based on URL type
            headers = None
            if file_entity.download_url.startswith("https://app.asana.com/"):
                headers = {"Authorization": f"Bearer {self.access_token}"}

            # Use the BaseSource helper method instead of direct file_manager calls
            processed_entity = await self.process_file_entity(
                file_entity=file_entity,
                headers=headers,
                access_token=self.access_token,  # Always pass the access token
            )

            yield processed_entity
Generate file attachment entities for a task.
backend/airweave/platform/sources/asana.py