Created
August 9, 2017 10:08
-
-
Save AndreasDickow/c244f0490ee90a25e138805c6fa63d7a to your computer and use it in GitHub Desktop.
Ionic2 file Upload to Django Rest Framework
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
class ProfileImageUploadView(views.APIView): | |
parser_classes = (FileUploadParser,) | |
permission_classes = (IsAccountOwner,) | |
def put(self, request, filename, format=None): | |
file_obj = request.data['file'] | |
if not request.user.is_anonymous(): | |
profile = request.user.profile | |
profile.profile_image = file_obj | |
profile.save() | |
# do some stuff with uploaded file | |
return Response(status=204) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment