Skip to main content

Fastapi Range Response

Description

  • HTTP range response for Fastapi
  • Part of the code is based on changes to BáiZé FileResponse
  • 实现了HTTP Range的响应类, 继承自starlette.response.Response, 可使用本机文件或sftp协议进行读取文件

Install

pip install fastapi_range_response

QuickStart

A short example for fastapi application

import asyncio
import asyncssh
from fastapi import FastAPI
from fastapi import Query
from fastapi_range_response import FileRangeResponse, AsyncsshRangeResponse

app = FastAPI()


@app.get('/local_file')
async def download_local_file(full_path: str = Query()):
    return FileRangeResponse(full_path, media_type='application/octet-stream')


@app.get('/download_sftp_file')
async def download_sftp_file(full_path: str = Query()):
    ssh_client = await asyncio.wait_for(
        asyncssh.connect(host='xxx', port=22, username='xxx', password='xxxx', known_hosts=None),
        timeout=10
    )
    return AsyncsshRangeResponse(full_path, ssh_client, done_close=True)


if __name__ == '__main__':
    import uvicorn

    uvicorn.run(app)

Metadata

Release files for fastapi-range-response 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastapi-range-response 0.1.1
File Size Uploaded Provenance Actions
fastapi_range_response-0.1.1.tar.gz 7.7 kB Without provenance Details for fastapi_range_response-0.1.1.tar.gz

Release files / fastapi_range_response-0.1.1.tar.gz

Download URL fastapi_range_response-0.1.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e1cf80144cd50764ca6c11105cb4d017644ae2bc8deee451bcdf01a72a5e8096
BLAKE2b-256 checksum
How to use checksums
71aee934bfb751428af433e96061ce296bd97921a9c8eb5e3c5d9cdc501e1147
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.13

Security for fastapi-range-response 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page