Skip to content

Instantly share code, notes, and snippets.

@AndreasDickow
Created August 9, 2017 10:08
Show Gist options
  • Save AndreasDickow/c244f0490ee90a25e138805c6fa63d7a to your computer and use it in GitHub Desktop.
Save AndreasDickow/c244f0490ee90a25e138805c6fa63d7a to your computer and use it in GitHub Desktop.
Ionic2 file Upload to Django Rest Framework
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