#8222: Storage should reset file's cursor after saving
-------------------------------------------+--------------------------------
          Reporter:  julien                |         Owner:  nobody
            Status:  closed                |     Milestone:  1.0   
         Component:  File uploads/storage  |       Version:  SVN   
        Resolution:  wontfix               |      Keywords:        
             Stage:  Accepted              |     Has_patch:  1     
        Needs_docs:  0                     |   Needs_tests:  0     
Needs_better_patch:  0                     |  
-------------------------------------------+--------------------------------
Changes (by jacob):

  * status:  new => closed
  * resolution:  => wontfix

Comment:

 This change causes a test failure:

 {{{
 ======================================================================
 ERROR: test_large_upload
 (regressiontests.file_uploads.tests.FileUploadTests)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File
 
"/Users/jacob/Projects/Django/upstream/tests/regressiontests/file_uploads/tests.py",
 line 53, in test_large_upload
     response = self.client.post('/file_uploads/verify/', post_data)
   File "/Users/jacob/Projects/Django/upstream/django/test/client.py", line
 285, in post
     return self.request(**r)
   File
 "/Users/jacob/Projects/Django/upstream/django/core/handlers/base.py", line
 86, in get_response
     response = callback(request, *callback_args, **callback_kwargs)
   File
 
"/Users/jacob/Projects/Django/upstream/tests/regressiontests/file_uploads/views.py",
 line 52, in file_upload_view_verify
     obj.testfile.save(largefile.name, largefile)
   File
 "/Users/jacob/Projects/Django/upstream/django/db/models/fields/files.py",
 line 74, in save
     self._name = self.storage.save(name, content)
   File
 "/Users/jacob/Projects/Django/upstream/django/core/files/storage.py", line
 46, in save
     content.seek(0)
   File
 "/Users/jacob/Projects/Django/upstream/django/core/files/uploadedfile.py",
 line 88, in seek
     def seek(self, *args):          return self._file.seek(*args)
 ValueError: I/O operation on closed file

 ----------------------------------------------------------------------
 }}}

 This is because depending on what type of file `content` is, `seek()` may
 not be valid after the file's been saved.

 So I think you're right that this is invalid; you can always call `seek()`
 manually should you need to (or simply save the other file first, like you
 figured out).

-- 
Ticket URL: <http://code.djangoproject.com/ticket/8222#comment:6>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to