答案 0 :(得分:26)
答案 1 :(得分:8)
from django.core.files.base import *
class StreamFile(ContentFile):
"""
Django doesn't provide a File wrapper suitable
for file-like objects (eg StringIO)
"""
def __init__(self, stream):
super(ContentFile, self).__init__(stream)
stream.seek(0, 2)
self.size = stream.tell()
现在你可以做这样的事情 -
photo.image.save(name, StreamFile(io))
答案 2 :(得分:7)
答案 3 :(得分:0)