• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

lib/Net/Mosso/H03-Jul-2010-986473

t/H03-Jul-2010-188145

CHANGESH A D03-Jul-20101.4 KiB4535

MANIFESTH A D03-Jul-2010273 1211

META.ymlH A D03-Jul-2010947 3534

Makefile.PLH A D03-Jul-20101 KiB2825

READMEH A D03-Jul-20104.6 KiB145107

README

1NAME
2    Net::Mosso::CloudFiles - Interface to Mosso CloudFiles service
3
4SYNOPSIS
5      use Net::Mosso::CloudFiles;
6      use Perl6::Say;
7
8      my $cloudfiles = Net::Mosso::CloudFiles->new(
9          user => 'myusername',
10          key  => 'mysecretkey',
11      );
12
13      # list all containers
14      my @containers = $cloudfiles->containers;
15      foreach my $container (@containers) {
16          say 'have container ' . $container->name;
17      }
18
19      # create a new container
20      my $container = $cloudfiles->create_container(name => 'testing');
21
22      # use an existing container
23      my $existing_container = $cloudfiles->container(name => 'testing');
24
25      my $total_bytes_used = $cloudfiles->total_bytes_used;
26      say "used $total_bytes_used";
27
28      my $object_count = $container->object_count;
29      say "$object_count objects";
30
31      my $bytes_used = $container->bytes_used;
32      say "$bytes_used bytes";
33
34      # returns a Data::Stream::Bulk object
35      # as it may have to make multiple HTTP requests
36      my @objects = $container->objects->all;
37      foreach my $object (@objects) {
38          say 'have object ' . $object->name;
39          # also size, etag, content_type, last_modified
40      }
41      my @objects2 = $container->objects(prefix => 'dir/')->all;
42
43      # To create a new object
44      my $xxx = $container->object( name => 'XXX' );
45      $xxx->put('this is the value');
46
47      # To set metadata of an object:
48      $xxx->object_metadata({
49          description => 'this is a description',
50          useful_number => 17
51      });
52
53      # To create a new object with the contents of a local file
54      my $yyy = $container->object( name => 'YYY', content_type => 'text/plain' );
55      $yyy->put_filename('README');
56
57      # To fetch an object:
58      my $xxx2 = $container->object( name => 'XXX' );
59      my $value = $xxx2->get;
60      say 'has name ' . $xxx2->name;
61      say 'has md5 ' . $xxx2->etag;
62      say 'has size ' . $xxx2->size;
63      say 'has content type ' . $xxx2->content_type;
64      say 'has last_modified ' . $xxx2->last_modified;
65
66      # To fetch metadata of an object:
67      say 'metadata description ' . $xxx2->object_metadata->{'description'};
68      say 'metadata useful_number ' . $xxx2->object_metadata->{'useful_number'};
69
70      # To download an object to a local file
71      $yyy->get_filename('README.downloaded');
72
73      $object->delete;
74
75      $container->delete;
76
77DESCRIPTION
78    This module provides a simple interface to the Mosso Cloud Files
79    service. "Cloud Files is reliable, scalable and affordable web-based
80    storage for backing up and archiving all your static content". Find out
81    more at <http://www.mosso.com/cloudfiles.jsp>.
82
83    To use this module you will need to sign up to Mosso Cloud Files and
84    provide a "user" and "key". If you use this module, you will incurr
85    costs as specified by Mosso. Please check the costs. If you use this
86    module with your user and key you will be responsible for these costs.
87
88    I highly recommend reading all about Cloud Files, but in a nutshell data
89    is stored in objects. Objects are referenced by names and objects are
90    stored in containers.
91
92METHODS
93  new
94    The constructor logs you into Cloud Files:
95
96      my $cloudfiles = Net::Mosso::CloudFiles->new(
97          user => 'myusername',
98          key  => 'mysecretkey',
99      );
100
101  containers
102    List all the containers and return them as
103    Net::Mosso::CloudFiles::Container objects:
104
105      my @containers = $cloudfiles->containers;
106
107  create_container
108    Create a new container and return it as a
109    Net::Mosso::CloudFiles::Container object:
110
111      my $container = $cloudfiles->create_container(name => 'testing');
112
113  container
114    Use an existing container and return it as a
115    Net::Mosso::CloudFiles::Container object:
116
117      my $existing_container = $cloudfiles->container(name => 'testing');
118
119  total_bytes_used
120    Returns the total amount of bytes used in your Cloud Files account:
121
122      my $total_bytes_used = $cloudfiles->total_bytes_used;
123
124TESTING
125    Testing CloudFiles is a tricky thing. Mosso charges you a bit of money
126    each time you use their service. And yes, testing counts as using.
127    Because of this, this module's test suite skips testing unless you set
128    the following three environment variables, along the lines of:
129
130      CLOUDFILES_EXPENSIVE_TESTS=1 CLOUDFILES_USER=username CLOUDFILES_KEY=15bf43... perl t/simple.t
131
132SEE ALSO
133    Net::Mosso::CloudFiles::Container, Net::Mosso::CloudFiles::Object.
134
135AUTHOR
136    Leon Brocard <acme@astray.com>.
137
138COPYRIGHT
139    Copyright (C) 2008-9, Leon Brocard
140
141LICENSE
142    This module is free software; you can redistribute it or modify it under
143    the same terms as Perl itself.
144
145