"Instant" Upload to Rackspace CloudFiles
Using inotify and the ‘swift’ client tools it is possible to automatically upload files to cloudfiles as they are written to disk.
This code is untested and might cause planes to drop from the sky, use it at your own risk!
#!/bin/bash
DIRECTORY='/home/welby/'
CONTAINER='testing'
USERNAME="welbycloud"
KEY="APIKEYFORCLOUD"
VERSION="2.0"
inotifywait -mr --format '%w%f' -e close_write $DIRECTORY | while read filename; do
if [ ! -e "$1" ]; then
sleep 2
if [ ! -e "$1" ]; then
continue
fi
fi
swift upload -s -A https://auth.api.rackspacecloud.com/v1.0 -U $USERNAME -K $KEY -v $VERSION $CONTAINER $filename
done