File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -111,7 +111,7 @@ def to_representation(self, file):
111111 return ""
112112
113113 try :
114- with open ( file .path , "rb" ) as f :
114+ with file .open ( ) as f :
115115 return base64 .b64encode (f .read ()).decode ()
116116 except Exception :
117117 raise OSError ("Error encoding file" )
Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ class ImageFieldFile:
4444 def __init__ (self , path ):
4545 self .path = path
4646
47+ def open (self ):
48+ return open (self .path , "rb" )
49+
4750 def __init__ (self , image_path ):
4851 self .image = self .ImageFieldFile (path = image_path )
4952
@@ -53,6 +56,9 @@ class FieldFile:
5356 def __init__ (self , path ):
5457 self .path = path
5558
59+ def open (self ):
60+ return open (self .path , "rb" )
61+
5662 def __init__ (self , file_path ):
5763 self .file = self .FieldFile (path = file_path )
5864
You can’t perform that action at this time.
0 commit comments