Skip to content

Commit

Permalink
chore: update files section #2291
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-mihok committed Apr 8, 2024
1 parent 0aed21f commit e449f2e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Binary file added assets/examples/sample-document.pdf
Binary file not shown.
11 changes: 11 additions & 0 deletions website/docs/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ async def serve(q: Q):

See `examples/file_stream.py` for a complete example.

## Serving documents

Use `q.site.upload()` to upload document from your app to the Wave server. Use the returned paths in `ui.frame()` component.

```py
q.app.document_path, = await q.site.upload(['path/to/my/document.pdf'])
q.page['example'] = ui.form_card(box='1 1 7 7', items=[
ui.frame(path=document_path)
])
```

## Serving files directly from the Wave server

As an alternative to using the above `upload()` or `download()` mechanisms, you can make the Wave server (`waved`) directly serve the contents of one or more existing directories. If the Wave server and your app both have access to the directories on the file system, your app can simply create or copy files to the directories to make them accessible from web browsers.
Expand Down
4 changes: 2 additions & 2 deletions website/widgets/form/frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ q.page['example'] = ui.form_card(box='1 1 7 7', items=[
The frame is also a preffered way for displaying documents. Simply provide a path to the PDF file.

```py
q.page['example'] = ui.form_card(box='1 1 4 7', items=[
ui.frame(path='https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf')
q.page['example'] = ui.form_card(box='1 1 7 7', items=[
ui.frame(path='/assets/examples/sample-document.pdf')
])
```

Expand Down

0 comments on commit e449f2e

Please sign in to comment.