Refactored task attachment retrieval for the legacy API