Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOOLS-xxxx use more content-type: in manta uploads #62

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion tools/bits-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <name> <.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/x-iso9660-image"
else
# Default value... XXX KEBE ASKS use text/plain instead?
content_type="content-type: application/octet-stream"
fi
Comment on lines +80 to +83
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider returning an empty result and let manta sort it out.


# Caller should use quotes around this.
echo $content_type
}

function fatal {
echo "$(basename $0): error: $1"
exit 1
Expand Down Expand Up @@ -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,"
Expand Down