 URL = require 'url'
 Worker = require './worker'
 
+pkgcloud = require('pkgcloud')
+cloudClient = pkgcloud.storage.createClient
+    provider: 'rackspace'
+    username: config.RACKSPACE_USERNAME
+    apiKey: config.RACKSPACE_API_KEY
+    region: config.CONTENT_REGION
 
 ## HELPERS
 
 DIR_BY_ID_PATH = Path.join config.DATA_DIR, 'content-by-id'
 DIR_BY_URL_PATH = Path.join config.DATA_DIR, 'content-by-url'
-
-# TODO: this is a short term fix to support the content by url code-path
-# we should remove this when we move to a proper database
-try
-    DATABASE = require Path.join DIR_BY_URL_PATH, 'data.json'
-catch e
-    DATABASE = {}
-
-DIR_PATH_FROM_URL_TO_ID = Path.relative DIR_BY_URL_PATH, DIR_BY_ID_PATH
 
 # TODO: We should be generating random IDs instead of incrementing them.
 NEXT_ID_KEY = 'content:next.id'

    id = id.replace /([A-Z])/g, '_$1'
    Path.join DIR_BY_ID_PATH, "#{id}.json"

getFilePathForURL = (url) ->
    if idFile = DATABASE["#{hashURL url}.json"]
        Path.join DIR_BY_ID_PATH, idFile.replace '../content-by-id', ''
    else
        ''

getRedisKeyForId = (id) ->
    "content:id:#{id}"


        else
            idPath = getFilePathForId id
            FS.writeFile idPath, content._stringifyData(), _
            # TODO: Update content-by-url in Cloud Files

        # Either way now:
        enqueueForConversion content, _
