I get an error while executing the following line:
img = copy.deepcopy(img_file_obj)
img_file_obj has the following type:
<class 'werkzeug.datastructures.FileStorage'>
Can't create a deep copy of a file storage object?
ADDED
I probably need to explain why I'm trying to create a copy of the file storage object. At the end of my code, I execute:
img_obj.save(fname)
But before that I check how big the file is. I do it as follows:
img_obj.seek(0, os.SEEK_END)
size = img.tell()
The problem is that checking the size "destroys" the file. If I check the file size and then save it, I will get an empty file on disk. That is why I wanted to create a copy of the object file, check the size of the copy and, if the size is acceptable, save the original file object on disk.