()
| 687 | pass |
| 688 | |
| 689 | async def stream_generator(): |
| 690 | try: |
| 691 | async with session.get(link) as resp: |
| 692 | if resp.status != 200: |
| 693 | raise HTTPException( |
| 694 | status_code=resp.status, |
| 695 | detail=f"从OneDrive获取文件失败: {resp.status}" |
| 696 | ) |
| 697 | chunk_size = 65536 |
| 698 | while True: |
| 699 | chunk = await resp.content.read(chunk_size) |
| 700 | if not chunk: |
| 701 | break |
| 702 | yield chunk |
| 703 | finally: |
| 704 | await session.close() |
| 705 | |
| 706 | encoded_filename = quote(filename, safe='') |
| 707 | headers = { |