I try to run the following code but index.js turns out to be corrupted.
Any idea why?
gzip dist/production/index.js
mv dist/production/index.js.gz dist/production/index.js
s3cmd --access_key="$S3_ACCESS_KEY" --secret_key="$S3_SECRET_KEY" \
--acl-public --no-mime-magic --progress --recursive \
--exclude "dist/production/index.js" \
put dist/production/
"s3://${BUCKET}/something/${BUILD_IDENTIFIER}/production/" &
s3cmd --access_key="$S3_ACCESS_KEY" --secret_key="$S3_SECRET_KEY" \
--acl-public --no-mime-magic --progress --recursive \
--add-header="Content-Encoding:gzip" \
put dist/production/index.js
"s3://${BUCKET}/something/${BUILD_IDENTIFIER}/production/" &
wait
Notice the &
in the end of the two commands that makes two uploads to the same location in parallel.
Edit:
It works fine without parallalizing the process and making them running in the background. I wanted to make the process faster so i upload the heavy gzipped index.js
while the other files are uploaded.
Edit2:
What I get in the index.js that is uploaded is gibberish content like this:
��;mS�H���W �7�i"���k��8̪
Edit3:
Looks like the problem was with how I used exclude. It excludes relatively to the uploaded folder and not to the working directory.
--exclude "dist/production/index.js"
==> --exclude index.js
fixed it.