SCP a file to your web server and copy url

From your noodle to other noodles. Talk about ways to get the most from Hazel. Even exchange recipes for the cool rules you've thought up. DO NOT POST YOUR QUESTIONS HERE.

Moderators: Mr_Noodle, Moderators

SCP a file to your web server and copy url Sun Sep 04, 2016 5:51 pm • by carpii
This is a rule I use on a daily basis to share random files with people, via my public webserver, simply by dragging it into a folder on my desktop

In my case my public webserver is another machine on my LAN, but it could be a remote server too

    Hazel scp's the file to your web server, into the specified directory
    It then moves the local file into a subdirectory called History (you can remove this rule and just have Hazel delete the file if you prefer)
    Finally it copies the PUBLIC url of the file into your clipboard, ready to be pasted into IM or IRC etc

Image

SCRIPT 1

Shell: /bin/sh

Code: Select all
base=$(basename "$1")
fname=$(echo "${base}" | sed 's/ /_/g')
/usr/bin/scp "$1" your_login@your_server:"/www/nelson/hazel/$fname"


SCRIPT 2

Code: Select all
set text item delimiters to ":"
set file_name to last text item of (theFile as text)
tell application "Finder" to set the clipboard to the "http://your_server_address.homeip.net/hazel/" & file_name as text



Changes you need to make

in SCRIPT 1 - change "your_login@your_server:"/www/nelson/hazel/" to the login, hostname and destination directory of your server

in SCRIPT 2 - change http://your_server_address.homeip.net/hazel/ to point to the PUBLIC uri of your server

Finally, this is intended for sharing ad-hoc files (screenshots, data dumps, text files etc).
Its not meant as a way of publishing changes to your website pages
carpii
 
Posts: 7
Joined: Sun Sep 04, 2016 5:26 pm

Return to Tips & Tricks - DO NOT POST QUESTIONS