Python 错误:文件对象没有属性大小

Python 错误:文件对象没有属性大小,python,django,django-storage,Python,Django,Django Storage,我正在使用django存储将文件存储到AWS S3中。上传用于正常工作的文件。但当我从django 1.10降级到1.8时。我在item.item\u profile.save(filename.name,photofile)行遇到奇怪的错误 代码: 错误: AttributeError at /home/photoupload/ 'file' object has no attribute 'size' Request Method: POST Request URL: http://l

我正在使用
django存储
将文件存储到AWS S3中。上传用于正常工作的文件。但当我从django 1.10降级到1.8时。我在
item.item\u profile.save(filename.name,photofile)
行遇到奇怪的错误

代码:

错误:

 AttributeError at /home/photoupload/
'file' object has no attribute 'size'
 Request Method: POST
 Request URL: http://localhost:8000/home/photoupload/
 Django Version: 1.8.17
 Python Executable: /usr/bin/python
 Python Version: 2.7.3

     Traceback:
     File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
     132.response = wrapped_callback(request, *callback_args, **callback_kwargs)
     File "/home/sandesh/knowmenow/pythonserver/home/views.py" in PhotoUpload
      174.item.item_profile.save(filename.name,photofile)
     File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/files.py" in save
     106.         self._size = content.size

我不是很确定,但我想这可能与
photofile.close()
有关。试着把它放在
item.item\u profile.save(filename.name,photofile)的头上。
错误是对已关闭文件“”的I/O操作。
 AttributeError at /home/photoupload/
'file' object has no attribute 'size'
 Request Method: POST
 Request URL: http://localhost:8000/home/photoupload/
 Django Version: 1.8.17
 Python Executable: /usr/bin/python
 Python Version: 2.7.3

     Traceback:
     File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
     132.response = wrapped_callback(request, *callback_args, **callback_kwargs)
     File "/home/sandesh/knowmenow/pythonserver/home/views.py" in PhotoUpload
      174.item.item_profile.save(filename.name,photofile)
     File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/files.py" in save
     106.         self._size = content.size