NAME

Net::Mosso::CloudFiles - Interface to Mosso CloudFiles service

SYNOPSIS

use Net::Mosso::CloudFiles;
use Perl6::Say;

my $cloudfiles = Net::Mosso::CloudFiles->new(
    user => 'myusername',
    key  => 'mysecretkey',
);

# list all containers
my @containers = $cloudfiles->containers;
foreach my $container (@containers) {
    say 'have container ' . $container->name;
}

# create a new container
my $container = $cloudfiles->create_container('testing');

# use an existing container
my $existing_container = $cloudfiles->container('testing');

my $total_bytes_used = $cloudfiles->total_bytes_used;
say "used $total_bytes_used";

my $object_count = $container->object_count;
say "$object_count objects";

my $bytes_used = $container->bytes_used;
say "$bytes_used bytes";

# returns a Data::Stream::Bulk object
# as it may have to make multiple HTTP requests
my @objects = $container->objects->all;
foreach my $object (@objects) {
    say 'have object ' . $object->name;
    # also size, etag, content_type, last_modified
}
my @objects2 = $container->objects(prefix => 'dir/')->all;

my $xxx = $container->object( name => 'XXX' );
$xxx->put('this is the value');

my $value = $xxx->get;
say 'has size ' . $object->size;
say 'has md5 ' . $object->etag;
say 'has value ' . $object->value;
say 'has last_modified ' . $object->last_modified;

my $yyy = $container->object( name => 'YYY', content_type => 'text/plain' );
$yyy->put_filename('README');

$yyy->get_filename('README.downloaded');

$object->delete;

$container->delete;

DESCRIPTION

This module provides a simple interface to the Mosso CloudFiles service. It is "Scalable, dynamic storage. Use as much or little as you want and only pay for what you use". Find out more at http://cloud.rackspace.com/cloudfiles.jsp.

This is the first version of this module. The API will probably change and lots of documentation will be added.

TESTING

Testing CloudFiles is a tricky thing. Mosso charges you a bit of money each time you use their service. And yes, testing counts as using. Because of this, this modules's test suite skips testing unless you set the following three environment variables, along the lines of:

CLOUDFILES_EXPENSIVE_TESTS=1 CLOUDFILES_USER=username CLOUDFILES_KEY=15bf43... perl t/simple.t
CLOUDFILES_EXPENSIVE_TESTS

Set this to 1.

CLOUDFILES_USER
CLOUDFILES_KEY

AUTHOR

Leon Brocard <acme@astray.com>.

COPYRIGHT

Copyright (C) 2008-9, Leon Brocard

LICENSE

This module is free software; you can redistribute it or modify it under the same terms as Perl itself.