Refactor file_body for best practices

This commit is contained in:
Vinnie Falco committed 2017-07-20 08:15:29 -07:00
1 parent 56948edd27
commit 09df24ec62
5 files changed
+195 -130

No files matched your search

+8 -2
View File
@@ -106,11 +106,17 @@ responses which deliver file contents, and allowing for file uploads. In this
example we build the `file_body` type which supports both reading and writing
to a file on the file system.
First we declare the type itself, along with the required members:
First we declare the type with its nested types:
[example_http_file_body_1]
The `size` function is a simple call to retrieve the file size:
We will start with the definition of the `value_type`. Our strategy
will be to store the open file handle directly in the message
container through the `value_type` field. To use this body it will
be necessary to call `msg.body.open()` with the file first. This
ensures that the file exists throughout the operation and prevent
the race condition where the file is removed from the file system
in between calls.
[example_http_file_body_2]