The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::Mosso::CloudFiles::Object - Represent a Cloud Files object

SYNOPSIS

  # To create a new object
  my $xxx = $container->object( name => 'XXX' );
  $xxx->put('this is the value');

  # To create a new object with the contents of a local file
  my $yyy = $container->object( name => 'YYY', content_type => 'text/plain' );
  $yyy->put_filename('README');

  # To fetch an object:
  my $xxx2 = $container->object( name => 'XXX' );
  my $value = $xxx2->get;
  say 'has name ' . $xxx2->name;
  say 'has md5 ' . $xxx2->etag;
  say 'has size ' . $xxx2->size;
  say 'has content type ' . $xxx2->content_type;
  say 'has last_modified ' . $xxx2->last_modified;

  # To download an object to a local file
  $yyy->get_filename('README.downloaded');

DESCRIPTION

This class represents an object in Cloud Files. It is created by calling object or objects on a Net::Mosso::CloudFiles::Container object.

METHODS

name

Returns the name of the object.

  say 'has name ' . $object->name;

Fetches the metadata of the object:

  $object->head;

get

Fetches the metadata and content of an object:

  my $value = $object->get;

get_filename

Downloads the content of an object to a local file, checks the integrity of the file, sets metadata in the object and sets the last modified time of the file to the same as the object.

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

delete

Deletes an object:

  $object->delete;

put

Creates a new object:

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

put_filename

Creates a new object with the contents of a local file:

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

etag

Returns the entity tag of the object, which is its MD5:

  say 'has md5 ' . $object->etag;

size

Return the size of an object in bytes:

  say 'has size ' . $object->size;

content_type

Return the content type of an object:

  say 'has content type ' . $object->content_type;

last_modified

Return the last modified time of an object as a DateTime object:

  say 'has last_modified ' . $object->last_modified;

SEE ALSO

Net::Mosso::CloudFiles, Net::Mosso::CloudFiles::Container.

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.