Changes between Version 2 and Version 4 of Ticket #26495


Ignore:
Timestamp:
Apr 13, 2016, 12:41:32 AM (9 years ago)
Author:
Maxim Novikov
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #26495

    • Property Summary Storage save method wraps StringIO in File object which is identified as False.Saving StringIO using custom storage class may result in empty content written to file
  • Ticket #26495 – Description

    v2 v4  
    99            content = File(content)
    1010}}}
    11 For example if custom storage uses requests with post query.
     11For example if custom storage uses requests with post query and we are saving StringIO object.
    1212{{{
    1313#!python
     14from StringIO import StringIO
     15
     16from django.core.files.storage import Storage
    1417import requests
    15 class CustomStorage(object):
     18
     19class CustomStorage(Storage):
    1620    def _save(self, name, content, max_length=None):
    1721          requests.post('http://testhost.org/upload', data=content)
     22custom_storage = CustomStorage()
     23custom_storage.save('new_name', StringIO('content'))
    1824}}}
    1925But it will result in empty upload as bool(content) is False.
Back to Top