Skip to content

Commit

Permalink
Another grain payload fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolas committed Jul 4, 2019
1 parent a3081da commit 2a7bfb0
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions plexus/grainlog/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ def post(self, request, **kwargs):
# typical grainlog uploads are around 200k, which
# is small enough that I think we can get away
# with just turning it into a string in memory
payload = ''
for chunk in f.chunks():
payload.join(smart_text(chunk))
payload = smart_text(f.read())
encoded_payload = payload.encode('utf-8')

sha1 = hashlib.sha1(payload.encode('utf-8')).hexdigest() # nosec
gl = self.model.objects.create_grainlog(sha1=sha1, payload=payload)
sha1 = hashlib.sha1(encoded_payload).hexdigest() # nosec
gl = self.model.objects.create_grainlog(sha1=sha1, payload=encoded_payload)
return HttpResponseRedirect(reverse('grainlog-detail', args=[gl.id]))

0 comments on commit 2a7bfb0

Please sign in to comment.