Skip to content

Commit 2a7bfb0

Browse files
committed
Another grain payload fix
1 parent a3081da commit 2a7bfb0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

plexus/grainlog/views.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ def post(self, request, **kwargs):
3939
# typical grainlog uploads are around 200k, which
4040
# is small enough that I think we can get away
4141
# with just turning it into a string in memory
42-
payload = ''
43-
for chunk in f.chunks():
44-
payload.join(smart_text(chunk))
42+
payload = smart_text(f.read())
43+
encoded_payload = payload.encode('utf-8')
4544

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

0 commit comments

Comments
 (0)