I'm saving a POST uploaded file to disk by using a technique described here: How to copy InMemoryUploadedFile object to disk
from django.core.files.storage import default_storage
from django.core.files.base import ContentFile
from django.conf import settings
data = request.FILES['image']
path = default_storage.save('tmp/%s' % filename, ContentFile(data.read()))
tmp_file = os.path.join(settings.MEDIA_ROOT, path)
The file does get uploaded and stored at the specified location. However, the content is garbled. It's an image - and when I look at the stored file, I see, the characters are not the same and the image file is damaged. The filesize, however, is the same as the original.
I guess, I need to do some conversion before saving the file, but how/which...?