Skip to content

Instantly share code, notes, and snippets.

View baaratik93's full-sized avatar
🏠
Working from home

Mamadou THIAM baaratik93

🏠
Working from home
View GitHub Profile
@TiagoTi
TiagoTi / django.view.py
Created May 27, 2020 10:32
Django save InMemoryUploadedFile (a temporary uploaded file) to disk
from django.core.files.storage import default_storage
from django.core.files.base import ContentFile
file = request.FILES['your_file_fieldname']
path = default_storage.save('heart_of_the_swarm.txt', ContentFile(file.read()))
#https://twigstechtips.blogspot.com/2012/04/django-how-to-save-inmemoryuploadedfile.html