Permalink
Browse files

[doc] Updated README.md

  • Loading branch information...
1 parent e571531 commit a97487c6fdc27c0ae8c2417b3c650100bbd4fa0f @indexzero indexzero committed Dec 25, 2010
Showing with 39 additions and 8 deletions.
  1. +39 −8 README.md
View
@@ -20,26 +20,56 @@ A client implementation for Rackspace CloudFiles in node.js
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.
-### Authenticating
-Before we can do anything with cloudfiles, we have to authenticate. Authenticating is simple:
+### Getting Started
+Before we can do anything with cloudfiles, we have to create a client with valid credentials. Cloudfiles will authenticate for you automatically:
<pre>
var cloudfiles = require('cloudfiles');
- var example = {
+ var config = {
auth : {
username: 'your-username',
apiKey: 'your-api-key'
}
};
- cloudfiles.setAuth(example.auth, function () {
- // Work with Rackspace Cloudfiles from here
+ var client = cloudfiles.createClient(config);
+</pre>
+
+### Working with Containers
+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:
+
+<pre>
+ // Creating a container
+ client.createContainer({ name: 'myContainer' }, function (err, container) {
+ // Listing files in the Container
+ container.getFiles(function (err, files) {
+
+ });
+ });
+</pre>
+
+### Uploading and Downloading Files
+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.
+
+<pre>
+ // Uploading a file
+ client.addFile('myContainer', 'remoteName.txt', 'path/to/local/file.txt', function (err, uploaded) {
+ // File has been uploaded
+ });
+
+ // Downloading a file
+ client.getFile('myContainer', 'remoteName.txt', function (err, file) {
+ // File has been downloaded
+
+ // Save it to a location outside the cache
+ file.save({ local: 'path/to/local/file.txt' }, function (err, filename) {
+ // File has been saved.
+ });
+
});
</pre>
## Roadmap
-1. Finish writing this README.md and sample usage
-2. Implement Storage Object metadata APIs.
-3. Implement outgoing request pooling to increase concurrency.
+1. Implement Storage Object metadata APIs.
## Run Tests
All of the node-cloudfiles tests are written in [vows][2], and cover all of the use cases described above.
@@ -48,6 +78,7 @@ All of the node-cloudfiles tests are written in [vows][2], and cover all of the
</pre>
#### Author: [Charlie Robbins](http://www.charlierobbins.com)
+#### Contributors: [Fedor Indutny](http://github.com/donnerjack13589)
[0]: http://docs.rackspacecloud.com/files/api/cf-devguide-latest.pdf
[1]: http://nodejitsu.com

0 comments on commit a97487c

Please sign in to comment.