Storage component for LoopBack.
Go to file
Raymond Feng 9b0fe46fbd Add fs to sample 2013-06-25 13:06:54 -07:00
example Add fs to sample 2013-06-25 13:06:54 -07:00
lib Add fs to sample 2013-06-25 13:06:54 -07:00
test Add Container/File classes 2013-06-25 09:29:53 -07:00
.gitignore Initial commits 2013-06-24 14:07:12 -07:00
README.md Update README 2013-06-24 16:57:16 -07:00
package.json Update README 2013-06-24 16:57:16 -07:00

README.md

asteroid-storage-service

Aseteroid Storage Service

Storage

The asteroid-storage-service service is designed to make it easy to upload and download files to various infrastructure providers. Special attention has been paid so that methods are streams and pipe-capable.

To get started with a asteroid-storage-service client just create one:

  var client = require('asteroid-storage-service').createClient({
    //
    // The name of the provider (e.g. "file")
    //
    provider: 'provider-name',
  
    //
    // ... Provider specific credentials
    //
  });

Each compute provider takes different credentials to authenticate; these details about each specific provider can be found below:

Each instance of storage.Client returned from storage.createClient has a set of uniform APIs:

Container

  • client.getContainers(function (err, containers) { })
  • client.createContainer(options, function (err, container) { })
  • client.destroyContainer(containerName, function (err) { })
  • client.getContainer(containerName, function (err, container) { })

File

  • client.upload(options, function (err) { })
  • client.download(options, function (err) { })
  • client.getFiles(container, function (err, files) { })
  • client.getFile(container, file, function (err, server) { })
  • client.removeFile(container, file, function (err) { })

Both the .upload(options) and .download(options) have had careful attention paid to make sure they are pipe and stream capable:

Upload a File

  var storage = require('asteroid-storage-service'),
      fs = require('fs');
  
  var client = storage.createClient({ /* ... */ });
  
  fs.createReadStream('a-file.txt').pipe(client.upload({
    container: 'a-container',
    remote: 'remote-file-name.txt'
  }));

Download a File

  var storage = require('asteroid-storage-service'),
      fs = require('fs');
  
  var client = storage.createClient({ /* ... */ });
  
  client.download({
    container: 'a-container',
    remote: 'remote-file-name.txt'
  }).pipe(fs.createWriteStream('a-file.txt'));