Changes between Version 2 and Version 4 of Ticket #26495
- Timestamp:
- Apr 13, 2016, 12:41:32 AM (9 years ago)
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 9 9 content = File(content) 10 10 }}} 11 For example if custom storage uses requests with post query .11 For example if custom storage uses requests with post query and we are saving StringIO object. 12 12 {{{ 13 13 #!python 14 from StringIO import StringIO 15 16 from django.core.files.storage import Storage 14 17 import requests 15 class CustomStorage(object): 18 19 class CustomStorage(Storage): 16 20 def _save(self, name, content, max_length=None): 17 21 requests.post('http://testhost.org/upload', data=content) 22 custom_storage = CustomStorage() 23 custom_storage.save('new_name', StringIO('content')) 18 24 }}} 19 25 But it will result in empty upload as bool(content) is False.