From 02c1a2b8d33486b1631495fe13642cecf4d6ebe7 Mon Sep 17 00:00:00 2001 From: Dan McDonald Date: Mon, 21 Nov 2022 14:21:12 -0500 Subject: [PATCH 1/2] OS-xxxx use more content-type: in manta uploads --- tools/bits-upload.sh | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/tools/bits-upload.sh b/tools/bits-upload.sh index 5b3545a..f0f7aaa 100755 --- a/tools/bits-upload.sh +++ b/tools/bits-upload.sh @@ -58,6 +58,34 @@ UPDATES_IMGADM=/root/opt/imgapi-cli/bin/updates-imgadm PATH=$PATH:/root/opt/node_modules/manta/bin:/opt/tools/bin +function content_type +{ + filename="$1" + # basename <.ext> will strip .ext off. Will be == name if it's + # not .ext. + if [[ "$(basename $filename .tgz)" != "$filename" ]]; then + content_type="content-type: application/gzip" + elif [[ "$(basename $filename .gz)" != "$filename" ]]; then + content_type="content-type: application/gzip" + elif [[ "$(basename $filename .txt)" != "$filename" ]]; then + content_type="content-type: text/plain" + elif [[ "$(basename $filename .log)" != "$filename" ]]; then + content_type="content-type: text/plain" + elif [[ "$(basename $filename .html)" != "$filename" ]]; then + content_type="content-type: text/html" + elif [[ "$(basename $filename .json)" != "$filename" ]]; then + content_type="content-type: application/json" + elif [[ "$(basename $filename .iso)" != "$filename" ]]; then + content_type="content-type: application/octet-stream" + else + # Default value... XXX KEBE ASKS use text/plain instead? + content_type="content-type: application/octet-stream" + fi + + # Caller should use quotes around this. + echo $content_type +} + function fatal { echo "$(basename $0): error: $1" exit 1 @@ -155,7 +183,8 @@ function manta_upload { if [[ -z ${manta_md5} ]]; then # file doesn't exist, upload it - manta_run mput ${MANTA_VERBOSE} -f ${file} ${manta_object} + manta_run mput -H "$(content_type ${file})" ${MANTA_VERBOSE} \ + -f ${file} ${manta_object} [[ $? == 0 ]] || fatal "Failed to upload ${file} to ${manta_object}" elif [[ "$BITS_UPLOAD_OVERWRITE" == "false" ]]; then echo "${manta_object} already exists and matches local file," From e03e1918b511f5d2f65b21eb84c1d0b620674a6e Mon Sep 17 00:00:00 2001 From: Dan McDonald Date: Tue, 29 Nov 2022 12:12:36 -0500 Subject: [PATCH 2/2] Fix .iso type --- tools/bits-upload.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bits-upload.sh b/tools/bits-upload.sh index f0f7aaa..32715cf 100755 --- a/tools/bits-upload.sh +++ b/tools/bits-upload.sh @@ -76,7 +76,7 @@ function content_type elif [[ "$(basename $filename .json)" != "$filename" ]]; then content_type="content-type: application/json" elif [[ "$(basename $filename .iso)" != "$filename" ]]; then - content_type="content-type: application/octet-stream" + content_type="content-type: application/x-iso9660-image" else # Default value... XXX KEBE ASKS use text/plain instead? content_type="content-type: application/octet-stream"