Super simple Rackspace Cloud Files client
Rackit is a module for managing large collections of files on Rackspace Cloud Files. Rackit automatically creates containers as needed, and reauthenticates when the API token expires. Rackit also supports the generation of temporary, time-limited file URLs.
Cloud Files has a recommended limit of 50,000 files per container. Rackit knows this, and will automatically create new containers as necessary.
With Rackit, you specify a container prefix, such as 'file'. Then, Rackit will create containers ['file0', 'file1', ...] as necessary. Files can be uploded by passing local paths or readable streams.
$ npm install rackit
var rackit = ;// Initialize with your account informationrackit;
Optionally, you may create your own Rackit instance. This is necessary if you are accessing multiple Cloud File accounts.
var Rackit = Rackit;var myRackit ='user' : '<your Rackspace username>''key' : '<your Rackspace API key>';myRackit;
When initializing Rackit, here are the options and defaults:
user : '' // Your Rackspace usernamekey : '' // Your Rackspace API keyprefix : 'dev' // The prefix for your Cloud Files containers (may contain forward slash)authRegion : 'US' // Specifies the authentication API entry point - other option of 'UK'region : '' // Specifies the geographic datacenter to prefer - defaults to the user's default region. Explicit options of 'ORD', 'DFW', 'HKG', 'LON', 'IAD', 'SYD' are accepted.tempURLKey : null // A secret for generating temporary URLsuseSNET : falseuseCDN : trueuseSSL : true // Specifies whether to use SSL (https) for CDN linksverbose : false // If set to true, log messages will be generatedlogger : consolelog // Function to receive log messages
cloudpathis in the form 'container/file-name' and is used as input to other methods to uniquely identify a file. I recommend storing the
cloudpathin your database, although you could also store a CDN url.
Uploads a file to the cloud. The uploaded file will be given a random 24-character file name, unless specified.
Here is an example of passing a stream to Rackit:
var http = ;http
Returns an array of all uploaded objects in prefixed containers.
Downloads a file from the cloud. Returns a readable stream, or can write directly to a file.
Permanently deletes a file from the cloud.
Upserts the metadata for the specified cloud file.
Retrieves the metadata for the specified cloud file. An error will be returned if the file does not exist.
Returns a URI for a given file. If the ttl parameter is omitted, then a CDN URI will be returned (if the container is CDN enabled). If ttl is specified, a temporary URI will be given which is valid for ttl seconds.
Opposite of getURI. Returns a Cloudpath string given a file's CDN or temporary URI. The Cloudpath can then be used as input to other Rackit methods.
(The MIT License)
Copyright (C) 2014 Ross Johnson (email@example.com)
Copyright (C) 2014 Mazira, LLC
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.