mirror of
https://github.com/notwa/rc
synced 2024-11-05 08:19:03 -08:00
expose raw response in __notice_upload_to_*
for testing
This commit is contained in:
parent
752606119e
commit
552b685024
1 changed files with 22 additions and 19 deletions
41
sh/notice
41
sh/notice
|
@ -98,8 +98,8 @@ __notice_upload_to_org_c_net_paste() {
|
||||||
[ "${bytes:-0}" -le 50000000 ] || return 128 # approx, untested
|
[ "${bytes:-0}" -le 50000000 ] || return 128 # approx, untested
|
||||||
target=paste.c-net.org
|
target=paste.c-net.org
|
||||||
#normal="$(__notice_curl -gT "$1" "https://$target")" || return
|
#normal="$(__notice_curl -gT "$1" "https://$target")" || return
|
||||||
normal="$(__notice_curl -g --data-binary "@$filepath" -H "X-FileName: ${1##*/}" "https://$target")" || return
|
raw="$(__notice_curl -g --data-binary "@$filepath" -H "X-FileName: ${1##*/}" "https://$target")" || return
|
||||||
normal="https:${normal#*http*:}"; normal="${normal%%[!!-~]*}"
|
normal="https:${raw#*http*:}"; normal="${normal%%[!!-~]*}"
|
||||||
aux="$normal"
|
aux="$normal"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,9 +108,9 @@ __notice_upload_to_io_file() {
|
||||||
# wget should use --content-disposition when downloading
|
# wget should use --content-disposition when downloading
|
||||||
[ "${bytes:-0}" -le 2000000000 ] || return 128 # approx, untested
|
[ "${bytes:-0}" -le 2000000000 ] || return 128 # approx, untested
|
||||||
target=file.io
|
target=file.io
|
||||||
normal="$(__notice_curl -F "file=@$1" "https://$target")" || return
|
raw="$(__notice_curl -F "file=@$1" "https://$target")" || return
|
||||||
[ "${normal#'{"success":true,"status":200,'}" ] || return
|
[ "${raw#'{"success":true,"status":200,'}" ] || return
|
||||||
normal="https:${normal#*\"link\":\"https:}"; normal="${normal%%[\"]*}"
|
normal="https:${raw#*\"link\":\"https:}"; normal="${normal%%[\"]*}"
|
||||||
aux="$normal" # no direct link, i think it's based on User-Agent
|
aux="$normal" # no direct link, i think it's based on User-Agent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,8 +121,8 @@ __notice_upload_to_at_oshi() {
|
||||||
# NOTE: spaces are automatically converted (by the server) to underscores.
|
# NOTE: spaces are automatically converted (by the server) to underscores.
|
||||||
[ "${bytes:-0}" -le 5000000000 ] || return 128 # approx, untested
|
[ "${bytes:-0}" -le 5000000000 ] || return 128 # approx, untested
|
||||||
target=oshi.at
|
target=oshi.at
|
||||||
normal="$(__notice_curl -fF "f=@$1" -F expire=20160 "https://$target")" || return
|
raw="$(__notice_curl -fF "f=@$1" -F expire=20160 "https://$target")" || return
|
||||||
normal="https:${normal##*DL: http*:}"; normal="${normal%%[!!-~]*}"
|
normal="https:${raw##*DL: http*:}"; normal="${normal%%[!!-~]*}"
|
||||||
aux="$normal"
|
aux="$normal"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,8 +134,8 @@ __notice_upload_to_com_bashupload() {
|
||||||
[ "${bytes:-0}" -le 50000000000 ] || return 128 # approx, untested
|
[ "${bytes:-0}" -le 50000000000 ] || return 128 # approx, untested
|
||||||
target=bashupload.com
|
target=bashupload.com
|
||||||
# https://$target/${${1##*/}// /%20}
|
# https://$target/${${1##*/}// /%20}
|
||||||
normal="$(__notice_curl -gT "$1" "https://$target")" || return
|
raw="$(__notice_curl -gT "$1" "https://$target")" || return
|
||||||
normal="https:${normal#*http*:}"; normal="${normal%%[!!-~]*}"
|
normal="https:${raw#*http*:}"; normal="${normal%%[!!-~]*}"
|
||||||
aux="$normal?download=1"
|
aux="$normal?download=1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,9 +147,9 @@ __notice_upload_to_net_filebin() {
|
||||||
target=filebin.net
|
target=filebin.net
|
||||||
__notice_generate_id "$(date -u +%s)" || return
|
__notice_generate_id "$(date -u +%s)" || return
|
||||||
aux="https://$target/$REPLY"
|
aux="https://$target/$REPLY"
|
||||||
#normal="$(__notice_curl -gfT "$1" "$aux/$(__notice_urlencode ${1##*/})")" || return
|
#raw="$(__notice_curl -gfT "$1" "$aux/$(__notice_urlencode ${1##*/})")" || return
|
||||||
normal="$(__notice_curl -gfT "$1" "$aux/")" || return
|
raw="$(__notice_curl -gfT "$1" "$aux/")" || return
|
||||||
normal="${normal##*\"filename\": \"}"; normal="$aux/${normal%%\"*}"
|
normal="${raw##*\"filename\": \"}"; normal="$aux/${normal%%\"*}"
|
||||||
# optional: lock the bin so nobody can edit it, but anyone can still delete it.
|
# optional: lock the bin so nobody can edit it, but anyone can still delete it.
|
||||||
curl -sSX PUT "$aux" >/dev/null || true
|
curl -sSX PUT "$aux" >/dev/null || true
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,8 @@ __notice_upload_to_at_x0() {
|
||||||
# filenames are randomized. cannot manually delete nor specify expiry.
|
# filenames are randomized. cannot manually delete nor specify expiry.
|
||||||
[ "${bytes:-0}" -le 104857600 ] || return 128
|
[ "${bytes:-0}" -le 104857600 ] || return 128
|
||||||
target=x0.at
|
target=x0.at
|
||||||
normal="$(__notice_curl -fF "file=@$1" "https://$target")" || return
|
raw="$(__notice_curl -fF "file=@$1" "https://$target")" || return
|
||||||
|
normal="$raw"
|
||||||
aux="$normal"
|
aux="$normal"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +171,8 @@ __notice_upload_to_se_uguu() {
|
||||||
# filenames are randomized. cannot manually delete nor specify expiry.
|
# filenames are randomized. cannot manually delete nor specify expiry.
|
||||||
[ "${bytes:-0}" -le 67108864 ] || return 128
|
[ "${bytes:-0}" -le 67108864 ] || return 128
|
||||||
target=uguu.se
|
target=uguu.se
|
||||||
normal="$(__notice_curl -fF "files[]=@$1" "https://$target/upload?output=text")" || return
|
raw="$(__notice_curl -fF "files[]=@$1" "https://$target/upload?output=text")" || return
|
||||||
|
normal="$raw"
|
||||||
aux="$normal"
|
aux="$normal"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +181,8 @@ __notice_upload_to_com_cockfile() {
|
||||||
# filenames are randomized. cannot manually delete nor specify expiry.
|
# filenames are randomized. cannot manually delete nor specify expiry.
|
||||||
[ "${bytes:-0}" -le 134217728 ] || return 128
|
[ "${bytes:-0}" -le 134217728 ] || return 128
|
||||||
target=cockfile.com
|
target=cockfile.com
|
||||||
normal="$(__notice_curl -fF "files[]=@$1" "https://$target/upload.php?output=text")" || return
|
raw="$(__notice_curl -fF "files[]=@$1" "https://$target/upload.php?output=text")" || return
|
||||||
|
normal="$raw"
|
||||||
aux="$normal"
|
aux="$normal"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,9 +193,9 @@ __notice_upload_to_sh_envs() {
|
||||||
# banned MIME types: application/java-archive, application/java-vm
|
# banned MIME types: application/java-archive, application/java-vm
|
||||||
[ "${bytes:-0}" -le 536870912 ] || return 128
|
[ "${bytes:-0}" -le 536870912 ] || return 128
|
||||||
target=envs.sh
|
target=envs.sh
|
||||||
normal="$(__notice_curl -fF "file=@$1" -Fsecret= -Fexpires=336 "https://$target")" || return
|
raw="$(__notice_curl -fF "file=@$1" -Fsecret= -Fexpires=336 "https://$target")" || return
|
||||||
aux="$normal"
|
aux="$raw"
|
||||||
normal="$normal/${1##*/}"
|
normal="$raw/${1##*/}"
|
||||||
}
|
}
|
||||||
|
|
||||||
__notice_retrying() {
|
__notice_retrying() {
|
||||||
|
@ -213,7 +216,7 @@ __notice_retrying() {
|
||||||
}
|
}
|
||||||
|
|
||||||
__notice_upload() {
|
__notice_upload() {
|
||||||
unset REPLY aux bytes fancy file filepath interrupt normal pretty sanitized sha1 target
|
unset REPLY aux bytes fancy file filepath interrupt normal pretty raw sanitized sha1 target
|
||||||
file="${1:-missing argument}"
|
file="${1:-missing argument}"
|
||||||
|
|
||||||
file="$(readlink -f "$file")" || return 2 # also converts `\`s to `/`s
|
file="$(readlink -f "$file")" || return 2 # also converts `\`s to `/`s
|
||||||
|
|
Loading…
Reference in a new issue