Text files uploaded to S3 are encoded strangely?

后端 未结 7 1014
醉话见心
醉话见心 2021-01-03 19:05

This is the strangest error, and I don\'t even know where to start understanding what\'s wrong.

S3 has been working well, up until suddenly one day (yesterday) it st

7条回答
  •  伪装坚强ぢ
    2021-01-03 19:46

    For those who are using boto3 (python 3) to upload and are having strange characters instead of accentuation (such as in portuguese and french languages, for example), Toni Chaz's and Sony Kadavan's answers gave me the hint to fix. Adding ";charset=utf-8" to ContentType argument when calling put_object was enough to the accentuation be shown correctly.

    content_type="text/plain;charset=utf-8"
    bucket_obj.put_object(Key=key, Body=data, ContentType=content_type)
    

提交回复
热议问题