allow setting a custom Content_Type in the zipline function
This commit is contained in:
parent
44ba91adb5
commit
a4569e1d8f
1 changed files with 18 additions and 5 deletions
|
@ -36,6 +36,7 @@ function zipline {
|
||||||
readonly file=${1:?Please provide the path to the file you want to upload.}
|
readonly file=${1:?Please provide the path to the file you want to upload.}
|
||||||
readonly name=${2}
|
readonly name=${2}
|
||||||
readonly desktopentry=${3}
|
readonly desktopentry=${3}
|
||||||
|
readonly contenttype=${4}
|
||||||
readonly token=${ZIPLINE_TOKEN:?Environment variable ZIPLINE_TOKEN is not set. Please set it to your Zipline API token. I recommend placing it in a file at ~/.config/environment.d/zipline.conf}
|
readonly token=${ZIPLINE_TOKEN:?Environment variable ZIPLINE_TOKEN is not set. Please set it to your Zipline API token. I recommend placing it in a file at ~/.config/environment.d/zipline.conf}
|
||||||
readonly url=${ZIPLINE_URL:?Environment variable ZIPLINE_URL is not set. Please set it to the URL of your Zipline instance. I recommend placing it in a file at ~/.config/environment.d/zipline.conf}
|
readonly url=${ZIPLINE_URL:?Environment variable ZIPLINE_URL is not set. Please set it to the URL of your Zipline instance. I recommend placing it in a file at ~/.config/environment.d/zipline.conf}
|
||||||
|
|
||||||
|
@ -71,18 +72,24 @@ function zipline {
|
||||||
readonly use_send_notify=false
|
readonly use_send_notify=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if curl -sS -fH "authorization: $token" "${url%/}/api/upload" -F file="@$file" -H "Content-Type: multipart/form-data" >"$temp_file" 2>&1; then
|
if [[ -z "${contenttype}" ]]; then
|
||||||
|
readonly content_type="multipart/form-data"
|
||||||
|
else
|
||||||
|
readonly content_type=$contenttype
|
||||||
|
fi
|
||||||
|
|
||||||
|
if curl -sS -fH "authorization: $token" "${url%/}/api/upload" -F"file=@$file;type=$content_type" >"$temp_file" 2>&1; then
|
||||||
readonly link=$(jq -r '.files[0]' <"$temp_file" | tr -d '\n')
|
readonly link=$(jq -r '.files[0]' <"$temp_file" | tr -d '\n')
|
||||||
echo -n "$link" | clip
|
echo -n "$link" | clip
|
||||||
echo "Upload successful. Link copied to clipboard: $link"
|
echo "Upload successful. Link copied to clipboard: $link"
|
||||||
if $use_send_notify; then
|
if $use_send_notify; then
|
||||||
notify-send -a "$name" -u low -c transfer.complete -i "$file" -h "string:desktop-entry:$desktopentry" "Upload Successful" "Link copied to clipboard:\n$link"
|
notify-send -a "$name" -u low -c "transfer.complete" -i "$file" -h "string:desktop-entry:$desktopentry" "Upload Successful" "Link copied to clipboard:\n$link"
|
||||||
fi
|
fi
|
||||||
rm -f "$temp_file"
|
rm -f "$temp_file"
|
||||||
else
|
else
|
||||||
echo "Upload failed. Error message: $(<"$temp_file")"
|
echo "Upload failed. Error message: $(<"$temp_file")"
|
||||||
if $use_send_notify; then
|
if $use_send_notify; then
|
||||||
notify-send -a "$name" -u critical -c transfer.error -h "string:desktop-entry $desktopentry" "Upload Failed" "$(<"$temp_file")"
|
notify-send -a "$name" -u critical -c "transfer.error" -h "string:desktop-entry:$desktopentry" "Upload Failed" "$(<"$temp_file")"
|
||||||
fi
|
fi
|
||||||
rm -f "$temp_file"
|
rm -f "$temp_file"
|
||||||
return 1
|
return 1
|
||||||
|
@ -110,6 +117,12 @@ function spectacle-screenshot {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if $save_recording; then
|
||||||
|
readonly content_type="video/webm"
|
||||||
|
else
|
||||||
|
readonly content_type="image/png"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z "${2}" ]]; then
|
if [[ -z "${2}" ]]; then
|
||||||
if $save_recording; then
|
if $save_recording; then
|
||||||
readonly file=$(mktemp /tmp/spectacle-recording.XXXXXXXX.webm)
|
readonly file=$(mktemp /tmp/spectacle-recording.XXXXXXXX.webm)
|
||||||
|
@ -128,7 +141,7 @@ function spectacle-screenshot {
|
||||||
fi
|
fi
|
||||||
[ ! -s "$file" ] && return 1
|
[ ! -s "$file" ] && return 1
|
||||||
|
|
||||||
zipline "$file" Spectacle org.kde.spectacle.desktop
|
zipline "$file" Spectacle org.kde.spectacle.desktop "$content_type"
|
||||||
rm -f "$file"
|
rm -f "$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +169,7 @@ function flameshot-screenshot {
|
||||||
echo "Screenshot saved to $file"
|
echo "Screenshot saved to $file"
|
||||||
[ ! -s "$file" ] && return 1
|
[ ! -s "$file" ] && return 1
|
||||||
|
|
||||||
zipline "$file" Flameshot org.flameshot.Flameshot.desktop
|
zipline "$file" Flameshot org.flameshot.Flameshot.desktop image/png
|
||||||
rm -f "$file"
|
rm -f "$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue