Skip to content

Instantly share code, notes, and snippets.

@philippbosch
Created August 9, 2011 10:41
Show Gist options
  • Save philippbosch/1133738 to your computer and use it in GitHub Desktop.
Save philippbosch/1133738 to your computer and use it in GitHub Desktop.
Saving raw POST data to a file field in Django
from django.core.files.base import ContentFile
uploaded_file = ContentFile(request.raw_post_data)
uploaded_file.name = "filename.txt"
my_object.file = uploaded_file
my_object.save()
@ijharulislam
Copy link

Thanks. This helped me a lot.

@liaogx
Copy link

liaogx commented Jul 17, 2019

It doesn't work!

@pomponchik
Copy link

its not working.

@philippbosch
Copy link
Author

@pomponchik thanks so much for the constructive and helpful comment.

@danielbenedykt
Copy link

Works great. Thanks

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