webiny-js
webiny-js copied to clipboard
Don't use utf8 encoding when reading files for upload after deploy
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.
Hi Pavel, I have made the necessary edit to the code and I'll go ahead to open a pull request.
Closed by @chiizzy1, thanks again 🍻 !