Unable to open uploaded file when using Django1.8, I am facing an error "ValueError: I/O operation on closed file". But this works well and good in Django 1.6:
Django1.8
>>>type(in_file)
<class 'django.core.files.uploadedfile.TemporaryUploadedFile'>
>>>in_file.closed
True
Django1.6
>>>type(in_file)
<class 'django.core.files.uploadedfile.TemporaryUploadedFile'>
>>>in_file.closed
False
def save_to_file(in_file, dest_file, type='w'):
try:
with open(dest_file, type) as out_file:
for line in in_file:
out_file.write(line)
except Exception as e:
print "Error::--{}".format(e)
>>>save_to_file(in_file, '/Work/YYY.FLAT')
Error::--I/O operation on closed file
There is similar bug reported on openstack forum along with the fix. Refer the post here and fix here. Your code might look like as ,