Skip to content

Commit

Permalink
update metadata only, on API call
Browse files Browse the repository at this point in the history
  • Loading branch information
mgogoulos committed Sep 20, 2024
1 parent d665058 commit 94c646f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions files/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,14 +598,15 @@ def put(self, request, friendly_token, format=None):
media = self.get_object(friendly_token)
if isinstance(media, Response):
return media

serializer = MediaSerializer(media, data=request.data, context={"request": request})
if serializer.is_valid():
if request.data.get('media_file'):
media_file = request.data["media_file"]
serializer.save(user=request.user, media_file=media_file)
else:
serializer.save(user=request.user)
serializer.save(user=request.user)
# no need to update the media file itself, only the metadata
#if request.data.get('media_file'):
# media_file = request.data["media_file"]
# serializer.save(user=request.user, media_file=media_file)
#else:
# serializer.save(user=request.user)
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

Expand Down

0 comments on commit 94c646f

Please sign in to comment.