Skip to content

Commit

Permalink
👀 preview doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
jiisanda committed Dec 11, 2023
1 parent 023691f commit a958c12
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/features/preview.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ file object.
- The temporary file is deleted as soon as it is closed. This is controlled by the `delete` parameter, which is `True`
by default. This is important to set it `True`, as if not done then it could fill up the server's storage.


In our case, we have set `delete=False`, and we have override the `FileResponse` to add a `__del__` method, which
will be deleting the file once the response is sent (see: `api/dependencies/repositories`).
Issue we were experiencing is due to the fact that the temporary file was getting deleted as soon as it's closed, which
happens when `with` block is exited. We were getting the following error `RuntimeError: File at path /tmp/tmpuc5ru1oh.png
does not exist.` And this is expected behaviour when `delete=True` is set in `tempfile.NamedTemporaryFile`.


The following figure describes how Preview in DocFlow works.

![preview-document](../imgs/document/document_preview.png)
Expand Down

0 comments on commit a958c12

Please sign in to comment.