Share screenshots, own your data

in Geek Inside

I’ve used image sharing software for the past 5 years: CloudApp, Cloudup, Droplr, I tried them all. Those apps are great to quickly share screenshots, annotated images, gifs, or even screencasts with users. Sometimes, an image is worth a thousand words. :)

When I switched to Linux for my February challenge, I set out to find a cross-platform alternative to all those services. Here is what I came up with.

While all those media sharing apps usually work well, they have a catch: you’re not in control of your data. If that service ever goes down you’ll lose your images and only leave dead links behind. You’re also uploading a lot of things to a server you don’t own and control.

My solution: upload all those images to a server I own. This isn’t enough though. I need a solution where images will be automatically uploaded to that server as soon as I need them, and where the image URL will be copied to my clipboard so I can immediately use it.

Here are the tools I used to get this to work:

  1. A friendly hosting provider. I chose Webfaction, where this site is hosted. There, I set up an app where the files were be served via nginx, on a cookie-less domain, with caching headers set to expires max.
  2. A domain set up to be cached and served via CloudFlare. This allows me not to worry about using too much bandwidth on my hosting plan. My images will also be served faster.
  3. Unison, installed on my machine and on my Webfaction plan (here is the tutorial). This will be used to automatically upload files from a specific directory on my machine to my app on Webfaction.
  4. launchd to trigger Unison every time an image is added to a specific directory on my machine.
  5. The Alfred productivity app on Mac, and its paid powerpack. I only use this to trigger a script on demand.
  6. An Alfred workflow. It doesn’t do much: it listens to the ig command, and runs a bash script, automator /Users/username/Utilities/share-screenshots.workflow
  7. An Automator workflow that does a few things to get my images ready to be uploaded, and get me an URL once the image can be shared.

To summarize, here is the flow:

  1. I make a screenshot using Mac OS’s built-in screenshot feature.
  2. If I want to share that screenshot, I invoke my Alfred workflow.
  3. In turn, the Alfred workflow triggers the Automator workflow.
  4. The Automator workflow looks for images in the directory where Mac OS saves my screenshots. If it finds the image, it renames it (I don’t like the spaces in the screenshots saved by Mac OS), and moves it to another folder. It then picks the file name, and generates a URL I can share. It copies that URL to my clipboard.
  5. In the background, launchd and its WatchPaths option have noticed the new file in that folder, and triggered Unison.
  6. Unison has synchronized that new file with the directory on my server.
  7. Done!

Want to see it in action? Here you go!

Magic!

If you’re willing to let your media sharing app go, this could be a good alternative in my opinion. Give it a try and let me know!

Leave a Reply