Send data according to the type of content

This commit is contained in:
Jeremy Gardais 2020-03-12 10:36:10 +01:00
parent 7ebf2031b0
commit 13647e0d8f
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 17 additions and 1 deletions

View File

@ -14,6 +14,7 @@ flag_clipboard=false
flag_inline=false flag_inline=false
flag_file=false flag_file=false
flag_url=false flag_url=false
flag_text=false
null_service_url="https://null.101010.fr" null_service_url="https://null.101010.fr"
@ -120,7 +121,22 @@ debug_message " Get Content: content to be sended: ${content_to_send}"
# Try to determine the type of the content (file, remote URL or text) # Try to determine the type of the content (file, remote URL or text)
determine_content_type "${content_to_send}" determine_content_type "${content_to_send}"
content_url="" # Try to send the content according to it's type [[[
if [ "${flag_file}" = "true" ]; then
## Command to send a local file to 0x0 service
debug_message " send data: Send it as a file"
content_url=$(curl -sF"file=@${content_to_send}" "${null_service_url}")
elif [ "${flag_url}" = "true" ]; then
## Command to send a remote URL to 0x0 service
debug_message " send data: Send it as a remote URL"
content_url=$(curl -sF"url=${content_to_send}" "${null_service_url}")
else
## Otherwise, it's a content
flag_text=true
debug_message " send data: Send it as a text"
content_url=$(printf "%b" "${content_to_send}" | curl -sF'file=@-;' "${null_service_url}")
fi
# ]]]
# Manage the result [[[ # Manage the result [[[
## If the URL should simply be printed to stdout ## If the URL should simply be printed to stdout