↓ Archives ↓

Posts Tagged → dropbox

Send E-Mail attachments to Dropbox

At Planio and LAUNCH/CO, we receive a lot of PDF receipts for things we purchase online or services we use regularly. I want all those files to go directly into a designated folder in my Dropbox and I don’t want to look at them until the end of the month when I zip everything together and send it to our accountant.

For this purpose, I have been using a service called send to dropbox for a while until it started getting unreliable. Soon it didn’t upload any of the e-mails anymore without even supplying an error message and I ended up fiddling with my e-mail attachments by hand again. Not very funny.

So, I hacked together something that “works for me” (TM) and doesn’t rely on an external service. Well, in fact, I am still relying on Uberspace to host this, but (a) I could easily do this everywhere else and (b) it’s a huge improvement over send to dropbox which felt more like a blackbox.

This is how it’s done on Uberspace, but really the instructions are very much applicable to any Linux based setup.

Download and Setup Dropbox Uploader

Dropbox Uploader is an awesome little shell script written by Andrea Fabrizi which can be used to upload files to Dropbox from the command line. It is very handy since it has no dependencies except for curl. For my purpose, it needed a little tweaking since it would not accept files from standard input, so I forked it and am currently waiting if my pull request is being merged. I will update this article as soon as it does, since I have no interest in maintaining the fork. Andrea seems to be doing an awesome job with this.

So open a shell on your Uberspace and do the following:

mkdir -p ~/opt
cd ~/opt
git clone git://github.com/yeah/Dropbox-Uploader.git
mkdir ~/bin
ln -s ~/opt/Dropbox-Uploader/dropbox_uploader.sh ~/bin/

This installs the latest version of Dropbox Uploader in ~/opt/Dropbox-Uploader and creates a handy symlink to it in ~/bin which should be in your PATH already.

To verify if that last assumption is true (and to authenticate Dropbox Uploader), simply run

dropbox_uploader.sh

It should lead you through the process of creating your own Dropbox App and authenticating your copy of Dropbox Uploader against it. If asked for the Access Level I’d opt for App folder since this won’t give the app access to your entire Dropbox. Your credentials are stored in ~/.dropbox_uploader which is 600 by default, but if you’re a bit paranoid like me, App folder is still the safer bet.

If you’d like to test Dropbox Uploader, perform a simple upload like this:

echo "hello dropbox world?" | dropbox_uploader.sh upload - hello_world.txt

A file called hello_world.txt should magically appear in your Dropbox. Does it work? Yay! Then here comes the fun part…

Configuring qmail and reformime

Again, it should not be hard to adapt this to other MTAs, but since Uberspace uses qmail (or netqmail to be more specific) this tutorial is written for that.

At Uberspace, you get an unlimited number of e-mail addresses out of the box. Your primary is composed like this:

username@hostname.uberspace.de

Where username is your Uberspace username and hostname is the host your account is hosted on. What happens to e-mails coming this way is governed by a small file named ~/.qmail. In much the same way, you can use any e-mail address that follows this format:

username-foo@hostname.uberspace.de

Where foo can be anything you like. To specify what should happen with e-mails coming in via this address, you can create a file called ~/.qmail-foo.

So, for instance, if you want all e-mail PDF attachments sent to peter-dropbox@phoenix.uberspace.de to appear in your Dropbox, create a ~/.qmail-dropbox file with the following content:

| /usr/bin/reformime -X /bin/sh -c "if [ "\${FILENAME#*.}" == "pdf" ]; then ~/bin/dropbox_uploader.sh upload - \"\$FILENAME\";fi"

Yep. That’s one single line. It uses reformime to extract all file attachments and then uploads those that end in .pdf to your Dropbox using Dropbox Uploader.

Try it out. It should already work. There’s nothing else to do.

Update: We don’t trust Dropbox much anymore since the whole NSA stuff and the end of safe harbor agreement. The above also works great with ownCloud though, too.

Sparkleshare

Today a release candidate for sparkleshare 0.2 came out. Thanks to @jan for making me notice this great software a few days ago. It’s kind of a dropbox or ubuntu one clone but completely open source. You can use it to store your local data on a public server, your own server, your intranet or wherever you trust to put our data. All you need is a git server, ssh and a certificate to access it. No matter if it’s your local data storage, github or plan.io.

Comparing it to dropbox of course there still are a lot of downsides given its early state. There is no sophisticated encryption, only the data transfer is encrypted using ssl certificates. There is no GUI for easy sharing of data: whoever has access to your git repository can access your data, but no one else. However there are already a few nice features working quite well. Among them the easy GUI-based setup, the automatic syncing and the nice way to access old versions o data: right-click on a file, choose a version and a new file appears with the old date in its file name.

There is the source code for linux and mac versions available, binaries and a windows version are expected at a later point of time. In case you are on Ubuntu or Debian I recommend the following steps for installation after getting and unpacking the source from hbons’ github:

# install dependencies for the build process
sudo apt-get install gtk-sharp2 mono-runtime mono-devel monodevelop \
libndesk-dbus1.0-cil-dev nant libnotify-cil-dev libgtk2.0-cil-dev \
libwebkit-cil-dev intltool libtool python-nautilus libndesk-dbus-glib1.0-cil-dev

# using the prefix you enable the nautilus extension
./configure --prefix=/usr

# compile
make

# use checkinstall instead of make install to install it as a clean debian package
# that can be easily uninstalled using your favorite package manager
sudo checkinstall

# start the service
sparkleshare start

# You possibly have to restart nautilus to enable the plugin
nautilus -q

So go try it out!