From 473ff70e991165229eb686c0a65c18ace46f82f7 Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Mon, 28 Sep 2020 15:07:35 +0200 Subject: [PATCH] Merge pull request #3235 from overleaf/jpa-cdn-upload-set-charset [bin/cdn_upload] set the charset for stylesheets and javascript files GitOrigin-RevId: f93565ef9475595de64611e04e3f4eca118f5218 --- services/web/bin/cdn_upload | 47 +++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/services/web/bin/cdn_upload b/services/web/bin/cdn_upload index 5b82ae6d53..7644dbfaef 100755 --- a/services/web/bin/cdn_upload +++ b/services/web/bin/cdn_upload @@ -1,6 +1,49 @@ #!/bin/bash set -e +function upload_with_content_type() { + content_type=$1 + bucket=$2 + shift 2 + content_type_options="" + if [[ "$content_type" != "-" ]]; then + content_type_options="-h Content-Type:${content_type};charset=utf-8" + fi + + # DOCS for gsutil -- it does not have long command line flags! + ## global flags + # -h NAME:VALUE add header, can occur multiples times + # -m upload with multiple threads + ## rsync flags + # -r traverse into directories recursively + # -x Python regex for excluding files from the sync + gsutil \ + -h "Cache-Control:public, max-age=31536000" \ + ${content_type_options} \ + -m \ + rsync \ + -r \ + "$@" \ + "/tmp/public/" \ + "${bucket}/public/" +} +function upload_into_bucket() { + bucket=$1 + + # stylesheets + upload_with_content_type 'text/css' "$bucket" \ + -x '.+(?