Ticket #7769: uploaded_file.diff
File uploaded_file.diff, 2.0 KB (added by , 16 years ago) |
---|
-
django/core/files/uploadedfile.py
199 199 # We can't directly subclass because NamedTemporaryFile is actually a 200 200 # factory function 201 201 def read(self, *args): return self._file.read(*args) 202 def seek(self, offset): return self._file.seek(offset)202 def seek(self, *args): return self._file.seek(*args) 203 203 def write(self, s): return self._file.write(s) 204 def tell(self, *args): return self._file.tell(*args) 204 205 def close(self): return self._file.close() 205 206 def __iter__(self): return iter(self._file) 206 207 def readlines(self, size=None): return self._file.readlines(size) … … 212 213 """ 213 214 def __init__(self, file, field_name, name, content_type, size, charset): 214 215 super(InMemoryUploadedFile, self).__init__(name, content_type, size, charset) 215 self. file = file216 self._file = file 216 217 self.field_name = field_name 217 self. file.seek(0)218 self._file.seek(0) 218 219 219 def seek(self, *args, **kwargs):220 self.file.seek(*args, **kwargs)221 222 220 def open(self): 223 self. seek(0)221 self._file.seek(0) 224 222 225 def read(self, *args, **kwargs):226 return self.file.read(*args, **kwargs)227 228 223 def chunks(self, chunk_size=None): 229 self. file.seek(0)224 self._file.seek(0) 230 225 yield self.read() 231 226 232 227 def multiple_chunks(self, chunk_size=None): 233 228 # Since it's in memory, we'll never have multiple chunks. 234 229 return False 230 231 # proxy methods to StringIO 232 def read(self, *args): return self._file.read(*args) 233 def seek(self, *args): return self._file.seek(*args) 234 def write(self, s): return self._file.write(s) 235 def tell(self, *args): return self._file.tell(*args) 236 def close(self): return self._file.close() 235 237 236 238 class SimpleUploadedFile(InMemoryUploadedFile): 237 239 """