webiny-js icon indicating copy to clipboard operation
webiny-js copied to clipboard

Don't use utf8 encoding when reading files for upload after deploy

Open Pavel910 opened this issue 3 years ago • 1 comments

Version

5.31.0

What are the steps to reproduce this bug?

Create a 5.31. project, or upgrade an older project to that version, and run a deploy.

What is the expected behavior?

Non-text files are uploaded to S3 bucket correctly, and are accessible.

What do you see instead?

Static non-text assets (images, videos), are broken/inaccessible. Also, if you check the S3 bucket, these files have a wrong file size.

Possible solution

The solution is to remove the utf8 encoding parameter from the call to fs.readFileSync: https://github.com/webiny/webiny-js/blob/next/packages/pulumi-aws/src/utils/uploadFolderToS3.ts#L142

By simply removing that argument, readFileSync will read a raw buffer, which will result in a correct file content uploaded to the S3 bucket.

Pavel910 avatar Sep 16 '22 16:09 Pavel910

Hi Pavel, I have made the necessary edit to the code and I'll go ahead to open a pull request.

chiizzy1 avatar Sep 20 '22 22:09 chiizzy1

Closed by @chiizzy1, thanks again 🍻 !

adrians5j avatar Sep 27 '22 15:09 adrians5j