I get an error message when I execute the following line:
img = copy.deepcopy(img_file_obj)
The img_file_obj
has the following type:
<class 'werkzeug.datastructures.FileStorage'>
Is it not allowed to create a deep copy of a file storage object?
ADDED
I probably need to explain why I am trying to create a copy of a file-storage object. In the end of my code I execute:
img_obj.save(fname)
But before that I check how big the file is. I do it in the following way:
img_obj.seek(0, os.SEEK_END)
size = img.tell()
The problem is that the checking of the size "destroys" the file. If I check the file size and then save it, I get an empty file on the disk. It is why I wanted to create a copy of the file-object, check the size of the copy and, if the size is acceptable, save the original file-object on the disk.
FileStorage
not being deepcopy-able and for that question's deepcopy working but not doing as the OP expected. – Barghest