Skip to content

Instantly share code, notes, and snippets.

@TiagoTi
Created May 27, 2020 10:32
Show Gist options
  • Save TiagoTi/4328ba5d0986cbc0a68dd85c61446b4b to your computer and use it in GitHub Desktop.
Save TiagoTi/4328ba5d0986cbc0a68dd85c61446b4b to your computer and use it in GitHub Desktop.
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
@baaratik93
Copy link

Thanks, it was usefull for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment