Linux currently misses an out of the box solution for easy upload.
It should:
A bash script can be made that is called on various triggers. It can be configured inside the desktop environment of choice.
function upload_image
{
client_id="xxx"
link=$(curl -s --request POST --url https://api.imgur.com/3/image --header \
"Authorization: Client-ID ${client_id}" --header "content-type: multipart/form-data;" \
-F "image=@${1}" | jq -r '.data.link')
$(echo "$link" | tr -d '\n' | xsel -ib)
notify-send "Image Uploaded"
}
function upload_text
{
dtime=`date '+%Y-%m-%d-%H:%M:%S'`
id=$(curl -s --data "content=${1}&comment=${dtime}&mode_name=JavaScript" \
https://somepastebinservice.com/save.php | jq -r '.url')
url="https://somepastebinservice/${id}"
echo $url | tr -d '\n' | xsel -ib
notify-send "Text Uploaded"
}
function upload_file
{
fname=$(basename "$1")
dtime=`date '+%Y-%m-%d-%H:%M:%S'`
filename="${dtime}_${fname}"
/home/yo/scripts/dropbox_uploader.sh upload "$1" "$filename"
/home/yo/scripts/dropbox_uploader.sh share "$filename" | \
perl -ne 's/(.*?)(?=https)//; print' | tr -d '\n' | xsel -ib
notify-send "File Uploaded"
}
function check_file
{
if [[ $1 == *.jpg ]] || [[ $1 == *.jpeg ]] || [[ $1 == *.png ]] || [[ $1 == *.gif ]]; then
upload_image "$1"
elif $(file -bL --mime "$1" | grep -q '^text'); then
content=$(cat "$1")
upload_text "$content"
else
upload_file "$1"
fi
}
if [[ $# -gt 0 ]]; then
for file in "$@"
do
check_file "$file"
done
else
content=$(xsel -ob)
if [[ $content == "file://"* ]]; then
IFS=$'\n'; files=($content); unset IFS
for (( i=0; i<${#files[@]}; i++ ))
do
file=$(echo "${files[$i]#file://}")
check_file "$file"
done
else
upload_text "$content"
fi
fi
A script like this handles one or more files. It tries to determine which service should the content be uploaded to.
A right click shortcut can be created in KDE:
[Desktop Entry]
Type=Service
Icon=smiley-shape
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
MimeType=all/allfiles;
Actions=upload;
Encoding=UTF-8
[Desktop Action upload]
Name=Upload File
Icon=smiley-shape
Exec=/home/me/scripts/upload.sh '%f'