Upload to own server – Konqueror/Dolphin “Plugin”

This adds a nice action to the Dolphin menu for picture files, which uploads the files to my server, and displays a formatted link which can be directly pasted to the web and forums.

First we need to find the location of our service menus:

kde4-config --path services[/code]

I use the following to split the paths (I seem to have two directories), and use the second directory for installing my service menu.

echo `kde4-config --path services` | awk -F":" '{print $2;}'[/code]

Which actually defaults to:
/usr/share/kde4/services/

This already has a collection of service menus, all of which terminate in the extension .desktop.

I added a simple service menu, which allows me to right click any picture file in Dolphin, and choose Actions>Upload to server. It immediately transfers the file via ftp to my server, parses the location of the uploaded file, and displays a popup with the new uploaded path that can be directly pasted in forums. If need be, I can also display the BB code for forums.

Contents of the file /usr/share/kde4/services/uploadtoserver.desktop

[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=image/*
Actions=uploader

[Desktop Action uploader]
Name=Upload Picture to Server
Icon=/home/droidzone/Pictures/upload-icon.ico
Exec=konsole --hold -e /dzbin/uploader %u
[/code]
The Mime type makes sure that the action is shown for all picture types registered in Ubuntu.
Actions=uploader is just a unique identifier
The icon can be customized (any picture file of any resolution will do).
The Exec is the line which decides which application should be called for the action. Note that I've made konsole load a binary I've created in Basic (Sorry geeks. ;).

The program in Basic which can be compiled in FreeBasic (fbc) is listed below. If you'd like to download fbc or read documentation on fbc, head over to my site.

'Part One
'Upload files to ftp
open "commandfile.txt" for output as #1
dim as string linef,filename,clipb
dim as string qt=chr(34)
if command$="" then
shell "zenity --error --text='You have not specified a filename.nnAn example syntax is: nuptest curpic.jpeg' --title='Filename not specified' --width=500"
end
endif
linef="user [email protected] "+qt+"passwordforftpuser"+qt
print #1,linef
linef="binary"
print #1,linef
linef="cd /locationonserver/images/screenshots"
print #1,linef
'filename is the argument
linef="put "+command$
print #1,linef
linef="exit"
print #1,linef
close #1
shell "ftp -n ftp.mysite.com <commandfile .txt"
shell "rm commandfile.txt"
filename="http://droidzone.in/images/screenshots/"+command$

clipb="echo "+qt+filename+qt+" | xclip"
shell clipb
clipb="echo '"+filename+"' | xclip -selection clipboard"
shell clipb
shell "zenity --entry --text='One File uploaded to droidzone.innnThe URL is included below' --title='Picture uploaded' --entry-text='"+filename+"' --width=500"
end
[/code]


.
[/code]


You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.