
It means I can browse to the Dropbox folder that Hazel is watching and edit the image directly. It's actually convenient that files will be overwritten.
If a file already exists with the same name as the one being uploaded, this script will overwrite it without warning. If the folder does not already exist, the new_key method will create it for me. I added a couple of extra lines to get this structure for me. They exist as YEAR/MO, for example "2012/05". I structured the bucket folders like they are in my WordPress content directory. My S3 bucket name is "" so that I could use it as a subdomain for this site. Since the folder I use is in Dropbox, I can add an image or video right to Dropbox and get back an Amazon S3 link. I add a file to a folder and Hazel will upload it to the designated S3 account and add a link to my Link Log file in NVAlt and my clipboard stack. The actual body of the script is one line. Logfile.write(nowTime+' '+imageLink+'\n') # %% encode the file name and append the URL to the log file Key.set_contents_from_filename(localFilePath) Key = bucket.new_key(datePath+'/'+fileName) # Determine the current month and year to create the upload path # The method is generic enough to work with any S3 bucket that is passed.įileName = os.path.basename(localFilePath) # This is the method that does all of the uploading and writing to the log file. P = subprocess.Popen(, stdin=subprocess.PIPE) LogFilePath = "/Users/weatherh/Dropbox/Notes/Linkin_Logs.txt" It's a Dropbox file in my NVAlt notes folder # This is where I store my log file for these links. # This is how Hazel passes in the file path

Then this script goes into a new Hazel rule.įrom boto.s3.connection import S3Connection

I really only needed a few methods though. This is a mature library of methods for doing all sorts of stuff with Amazon AWS. I Installed the boto module for working with Amazon AWS. I'm a sucker for learning something new so I made this Python based Hazel rule. But in the middle of it, I received a polite prompt to make it work with Amazon S3 instead. I've been fiddling with my Hazel Dropbox to FTP rule lately.
