Added brief documentation with an example for file_stream
Added test to ensure `file_stream()` works in the test suite.
This commit is contained in:
parent
e155fe403d
commit
181977ad4e
|
@ -60,6 +60,16 @@ async def index(request):
|
|||
return response.stream(streaming_fn, content_type='text/plain')
|
||||
```
|
||||
|
||||
## File Streaming
|
||||
For large files, a combination of File and Streaming above
|
||||
```python
|
||||
from sanic import response
|
||||
|
||||
@app.route('/big_file.png')
|
||||
async def handle_request(request):
|
||||
return await response.file_stream('/srv/www/whatever.png')
|
||||
```
|
||||
|
||||
## Redirect
|
||||
|
||||
```python
|
||||
|
|
|
@ -37,6 +37,10 @@ async def test_await(request):
|
|||
async def test_file(request):
|
||||
return await response.file(os.path.abspath("setup.py"))
|
||||
|
||||
@app.route("/file_stream")
|
||||
async def test_file_stream(request):
|
||||
return await response.file_stream(os.path.abspath("setup.py"),
|
||||
chunk_size=1024)
|
||||
|
||||
# ----------------------------------------------- #
|
||||
# Exceptions
|
||||
|
|
Loading…
Reference in New Issue
Block a user