aschn / drf-tracking

Utils to track requests to Django Rest Framework API views
http://drf-tracking.readthedocs.org/
ISC License
366 stars 95 forks source link

Failed Clean data when uploading file as form-data #125

Open joeldhenry opened 5 years ago

joeldhenry commented 5 years ago
UnicodeDecodeError
'utf-8' codec can't decode byte 0xff in position 400: invalid start byte

rest_framework_tracking/base_mixins.py in _clean_data at line 163
rnegron commented 5 years ago

It seems likely that the file you are trying to upload is encoded as UTF-16 or similar. In the _clean_data function, there is a line which tries to decode the incoming request data as UTF-8. That line is the cause of your issue.

I'm wondering what the best solution to fix this issue in the code is? Attempt to auto-detect encoding using chardet? Silently fail the data cleaning? Would be willing to implement a suggested solution.

josefkorbel commented 5 years ago

Also facing this issue while serving audio files.