[oe-commits] [bitbake] 33/44: toaster: open image files in binary mode when sending in response

git at git.openembedded.org git at git.openembedded.org
Mon Jun 13 21:11:21 UTC 2016


rpurdie pushed a commit to branch master-next
in repository bitbake.

commit a1059c0646529b02af80ab27c80427b203be7c29
Author: Elliot Smith <elliot.smith at intel.com>
AuthorDate: Tue Jun 7 16:37:29 2016 +0100

    toaster: open image files in binary mode when sending in response
    
    The view code for downloading image files used the "r" flag
    to read the file, then used the open file object to form the
    HTTP response.
    
    While this worked in Python 2, Python 3 appears to be more strict
    about this sort of thing, and Django throws a UnicodeDecodeError
    when a file opened this way is used in a response.
    
    Open the file with the "b" flag (binary mode) so that Django can
    correctly convert the binary file handle to an HTTP response.
    
    Signed-off-by: Elliot Smith <elliot.smith at intel.com>
    Signed-off-by: Ed Bartosh <ed.bartosh at linux.intel.com>
---
 lib/toaster/toastergui/views.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py
index 9121ea9..5ceeb6b 100755
--- a/lib/toaster/toastergui/views.py
+++ b/lib/toaster/toastergui/views.py
@@ -2338,7 +2338,7 @@ if True:
             )
 
             if file_name and response_file_name:
-                fsock = open(file_name, "r")
+                fsock = open(file_name, "rb")
                 content_type = MimeTypeFinder.get_mimetype(file_name)
 
                 response = HttpResponse(fsock, content_type = content_type)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list