diff --git a/src/drf_chunked_upload/views.py b/src/drf_chunked_upload/views.py index 5b9c177..d3bc90f 100644 --- a/src/drf_chunked_upload/views.py +++ b/src/drf_chunked_upload/views.py @@ -187,9 +187,12 @@ def _put_chunk(self, request, pk=None, whole=False, *args, **kwargs): pk=upload_id) self.is_valid_chunked_upload(chunked_upload) if chunked_upload.offset != start: - raise ChunkedUploadError(status=status.HTTP_400_BAD_REQUEST, - detail='Offsets do not match', - offset=chunked_upload.offset) + raise ChunkedUploadError( + status=status.HTTP_400_BAD_REQUEST, + detail='Offsets do not match', + expected_offset=chunked_upload.offset, + provided_offset=start, + ) chunked_upload.append_chunk(chunk, chunk_size=chunk_size) else: diff --git a/tests/test_uploads.py b/tests/test_uploads.py index 420bf64..a7b088f 100644 --- a/tests/test_uploads.py +++ b/tests/test_uploads.py @@ -189,7 +189,8 @@ def test_chunked_upload_wrong_order(view, user1): print(response.data) assert response.status_code == status.HTTP_400_BAD_REQUEST assert response.data['detail'] == 'Offsets do not match' - assert response.data['offset'] == 10 + assert response.data['expected_offset'] == 10 + assert response.data['provided_offset'] == 20 @pytest.mark.django_db