Depending on which aws cli version (v1 vs v2) you use, you need to consider the cli-binary-format option and its default:
The formatting style to be used for binary blobs. The default format is base64. The base64 format expects binary blobs to be provided as a base64 encoded string. The raw-in-base64-out format preserves compatibility with AWS CLI V1 behavior and binary values must be passed literally. When providing contents from a file that map to a binary blob fileb:// will always be treated as binary and use the file contents directly regardless of the cli-binary-format setting. When using file:// the file contents will need to properly formatted for the configured cli-binary-format.
Documentation: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/lambda/invoke.html