Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rackit

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rackit

Super simple Rackspace Cloud Files client

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by250%
Maintainers
1
Weekly downloads
 
Created
Source

Rackit

Rackit is a module for managing up to 3.2 bajillion** files on Rackspace Cloud Files. With Rackit, you don't have to worry about containers, CDN enabling containers, or re-authenticating when your key has expired.

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.

For security, privacy, and ease, Rackit stores files on the cloud with random names.

Install (coming soon)

$ npm install rackit

Usage

var rackit = require('rackit');

// Initialize with your account information
rackit.init({
    'user' : '<your Rackspace username>',
    'key' : '<your Rackspace API key>'
}, function(err) {
    // Add a local file to the cloud
    rackit.add('./image.jpg', function(err, cloudPath) {
        // Get the CDN URI of the file
        console.log(rackit.getURI(cloudPath));
    });
});

Optionally, you may create your own Rackit instance. This is necessary if you are accessing multiple Cloud File accounts.

var Rackit = require('rackit').Rackit;
var myRackit = new Rackit({
    'user' : '<your Rackspace username>',
    'key' : '<your Rackspace API key>'
});

myRackit.init(function(err) {
    // Add a local file to the cloud
    myRackit.add('./image.jpg', function(err, cloudPath) {
        // Get the CDN URI of the file
        console.log(myRackit.getURI(cloudPath));
    });
});

Options

When initializing Rackit, here are the options and defaults:

  • user: '' - your Rackspace username

  • key: '' - your Rackspace API key

  • prefix: 'dev' - the prefix for your Cloud Files containers

  • baseURI: 'https://auth.api.rackspacecloud.com/v1.0' - the API entry point, which may change depending on your country

  • useSNET: false - whether or not to use SNET for super-fast Cloud Server to Cloud File networking

  • useCDN: true - tells Rackit whether to CDN enable new containers it creates

  • useSSL: true - tells Rackit whether to use the SSL version of CDN URIs

  • verbose: false - if set to true, log messages will be generated

  • logger: console.log - if verbose is true, this function will recieve the log messages

Methods

#add(localPath, [options,] callback)

  • localPath - a path to the file to upload
  • options - a hash of additional options
    • type - a MIME type (e.g. 'Image/JPEG'). If not specified, mime-magic is used.
    • meta - a hash of additional metadata to store along with the file
  • callback(err, cloudPath) - cloudPath is of the form 'container/file-name' and is used by Rackit to identify the file

Uploads a file to the cloud. The uploaded file will be given a random 24-character file name.

#get(cloudPath, localPath, callback)

  • cloudPath - of the form 'container/file-name'
  • localPath - where to put the downloaded file
  • callback(err)

Downloads a file from the cloud.

#remove(cloudPath, callback)

Permanently deletes a file from the cloud.

#setMeta(cloudPath, meta, callback)

Upserts the metadata for the specified cloud file.

#getURI(cloudPath)

Returns the complete CDN URI for a given file. Will only work if the file's container is CDN enabled.

TODO

  • Finish writing test cases

** theoretical limit

Keywords

FAQs

Package last updated on 05 Mar 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc