'Python Django s3 error "file must be encoded before hashing"

We send a file via API.

When the file is saved locally or on the same ec2 instance, all works fine, and we get the response from the API

When the file is saved on AWS s3, we get the error 'Unicode-objects must be encoded before hashing'

This is the code that works to open and send file from local device but not when getting the file from s3

 my_file = self.original_file.open(mode='rb').read()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source