Код: Выделить всё
@router.get("..path", tags=["some tags"], summary=..., responses={404: {"model": ...}, 403: {"model": ...}, 307: {"model": ...}}, response_model_exclude_none=True)
async def download_file(
# there's a depends on an API key
blob_path: str = Query(
...
)):
credential = ClientSecretCredential(...) //secrets
blob_service_client = BlobServiceClient(f"https://{storage_account}.blob.core.windows.net", credential=credential)
user_delegation_key = blob_service_client.get_user_delegation_key(key_start_time=datetime.utcnow(),key_expiry_time=datetime.utcnow() + timedelta(minutes=30))
token = generate_blob_sas(account_name=...,
container_name=...,
blob_name=blob_path,
user_delegation_key=user_delegation_key,
permission=BlobSasPermissions(read=True),
expiry=datetime.utcnow() + timedelta(minutes=30))
blob_url = f'https://{storage_account}.blob.core.windows.net/{container_name}/{blob_path}?{token}'
print(blob_url)
response = RedirectResponse(blob_url)
return response
[img]https://i.sstatic. net/fsnmL.png[/img]

Я также заглянул на вкладку «Сеть», чтобы увидеть, что происходит с этим запросом:
[img]https://i. sstatic.net/M3Mbv.png[/img]

Похоже, есть запрос OPTIONS, и я предполагаю, что получаю ответ на этот запрос. Не уверен, что именно так Swagger обрабатывает запрос. Есть идеи, как/почему это происходит и как это исправить? Спасибо!
Подробнее здесь: https://stackoverflow.com/questions/736 ... swagger-ui