Skip to content

Instantly share code, notes, and snippets.

@mesuutt
Last active October 25, 2018 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mesuutt/3f989f56fa0f22b70f063bfeb34258c4 to your computer and use it in GitHub Desktop.
Save mesuutt/3f989f56fa0f22b70f063bfeb34258c4 to your computer and use it in GitHub Desktop.
Django save file to storage & Read from storage without model
from django.core.files.storage import default_storage
# Saving POST'ed file to storage
file = request.FILES['myfile']
filename = default_storage.save(file.name, file)
# Reading file from storage
file = default_storage.open(filename)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment