def get_image_in_memory_data():
"""
Creates the InMemoryUploadedFile object using thedata from io
to save it into the ImageField of the database
"""
io = get_image_data() # get a red rectangle 200x200px
# create the InMemoryUploadedFile object with the 'foo.jpg' file
image_file = InMemoryUploadedFile(io, None, 'foo.jpg',
'jpeg', sys.getsizeof(io), None)
image_file.seek(0) # seek to the beginning
return image_file
评论列表
文章目录