Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 97 lines (75 sloc) 2.947 kb
71df419 Charlie Robbins [api test] Added basic support for CloudFiles Containers and StorageObje...
indexzero authored
1 # node-cloudfiles
65b5c74 Charlie Robbins [doc] Updated README.md
indexzero authored
2
3 A client implementation for Rackspace CloudFiles in node.js
4
cbbae7f Charlie Robbins [doc] Updated README.md
indexzero authored
5 ## Installation
6
7 ### Installing npm (node package manager)
8 <pre>
9 curl http://npmjs.org/install.sh | sh
10 </pre>
11
12 ### Installing node-cloudfiles
13 <pre>
14 npm install cloudfiles
15 </pre>
16
17 ### [Getting Rackspace Account][4]
18
19 ## Usage
20
21 The node-cloudfiles library is compliant with the [Rackspace CloudFiles API][0]. Using node-cloudfiles is easy for a variety of scenarios: authenticating, creating and working with both containers and storage objects.
22
a97487c Charlie Robbins [doc] Updated README.md
indexzero authored
23 ### Getting Started
24 Before we can do anything with cloudfiles, we have to create a client with valid credentials. Cloudfiles will authenticate for you automatically:
cbbae7f Charlie Robbins [doc] Updated README.md
indexzero authored
25 <pre>
26 var cloudfiles = require('cloudfiles');
a97487c Charlie Robbins [doc] Updated README.md
indexzero authored
27 var config = {
cbbae7f Charlie Robbins [doc] Updated README.md
indexzero authored
28 auth : {
29 username: 'your-username',
30 apiKey: 'your-api-key'
31 }
32 };
a97487c Charlie Robbins [doc] Updated README.md
indexzero authored
33 var client = cloudfiles.createClient(config);
34 </pre>
35
36 ### Working with Containers
37 Rackspace Cloudfiles divides files into 'Containers'. These are very similar to S3 Buckets if you are more familiar with Amazon. There are a couple of simple operations exposed by node-cloudfiles:
38
39 <pre>
40 // Creating a container
41 client.createContainer({ name: 'myContainer' }, function (err, container) {
42 // Listing files in the Container
43 container.getFiles(function (err, files) {
44
45 });
46 });
47 </pre>
48
49 ### Uploading and Downloading Files
50 Each Container has a set of 'StorageObjects' (or files) which can be retrieved via a Cloudfiles client. Files are downloaded to a local file cache that can be configured per client.
51
52 <pre>
53 // Uploading a file
54 client.addFile('myContainer', 'remoteName.txt', 'path/to/local/file.txt', function (err, uploaded) {
55 // File has been uploaded
56 });
57
58 // Downloading a file
59 client.getFile('myContainer', 'remoteName.txt', function (err, file) {
60 // File has been downloaded
61
62 // Save it to a location outside the cache
63 file.save({ local: 'path/to/local/file.txt' }, function (err, filename) {
64 // File has been saved.
65 });
66
cbbae7f Charlie Robbins [doc] Updated README.md
indexzero authored
67 });
68 </pre>
69
70 ## Roadmap
71
a97487c Charlie Robbins [doc] Updated README.md
indexzero authored
72 1. Implement Storage Object metadata APIs.
cbbae7f Charlie Robbins [doc] Updated README.md
indexzero authored
73
74 ## Run Tests
dfcfc6f Charlie Robbins [doc dist] Added CHANGELOG.md, updated README.md, and added formal LICEN...
indexzero authored
75 All of the node-cloudservers tests are written in [vows][2], and cover all of the use cases described above. You will need to add your Rackspace API username and API key to test/data/test-config.json before running tests:
76 <pre>
77 {
78 "auth": {
79 "username": "your-username",
80 "apiKey": "your-apikey"
81 }
82 }
83 </pre>
84
85 Once you have valid Rackspace credentials you can run tests with [vows][2]:
cbbae7f Charlie Robbins [doc] Updated README.md
indexzero authored
86 <pre>
87 vows test/*-test.js --spec
88 </pre>
89
90 #### Author: [Charlie Robbins](http://www.charlierobbins.com)
a97487c Charlie Robbins [doc] Updated README.md
indexzero authored
91 #### Contributors: [Fedor Indutny](http://github.com/donnerjack13589)
cbbae7f Charlie Robbins [doc] Updated README.md
indexzero authored
92
93 [0]: http://docs.rackspacecloud.com/files/api/cf-devguide-latest.pdf
94 [1]: http://nodejitsu.com
95 [2]: http://vowsjs.org
96 [3]: http://blog.nodejitsu.com/nodejs-cloud-server-in-three-minutes
97 [4]: http://www.rackspacecloud.com/1469-0-3-13.html
Something went wrong with that request. Please try again.