Python Boto3 S3 Bucket Encryption result in 0 byte

2019-08-31 13:53发布

问题:

Needing some help here.

I have a Python script using Boto3 that does S3 Bucket encryption. It was working fine before this and just recently I noticed that when I use the script, it will cause the object to become 0 bytes. It is working just fine if I were to encrypt it manually via the console.

Is anyone facing similar issue and would you mind to share any workaround? At least to recover back the files. I am clueless here.

I've did a quick troubleshooting and found out that when below line is executed, it will change the files to become 0 bytes.

client.put_object(Bucket=bucket_name, Key=object_key, ServerSideEncryption='AES256')

Thank you very much for your help and assistance.

Regards, Ameer.

回答1:

That line of code is missing a Body parameter. You aren't telling it what file or contents to upload.