Last active
October 25, 2018 11:49
-
-
Save mesuutt/3f989f56fa0f22b70f063bfeb34258c4 to your computer and use it in GitHub Desktop.
Django save file to storage & Read from storage without model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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