| Net-Google-DocumentsList documentation | Contained in the Net-Google-DocumentsList distribution. |
Net::Google::DocumentsList::Role::Exportable - implementation of download items
use Net::Google::DocumentsList;
my $client = Net::Google::DocumentsList->new(
username => 'myname@gmail.com',
password => 'p4$$w0rd'
);
# pickup one document
my $d = $client->item;
# download and set to variable
my $content = $d->export(
{
format => 'txt',
}
);
# download to a file
$d->export(
{
format => 'txt',
file => '/path/to/download.txt',
}
);
This module implements download functionality.
downloads the item. available formats are seen in http://code.google.com/intl/en/apis/documents/docs/3.0/developers_guide_protocol.html#DownloadingDocs.
Noubo Danjou <nobuo.danjou@gmail.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Net-Google-DocumentsList documentation | Contained in the Net-Google-DocumentsList distribution. |
package Net::Google::DocumentsList::Role::Exportable; use Any::Moose '::Role'; use File::Slurp; requires 'item_feedurl', 'kind'; sub export { my ($self, $args) = @_; $self->kind eq 'folder' and confess "You can't export folder"; my $format = delete $args->{format}; my $file = delete $args->{file}; my $res = $self->service->request( { uri => $self->item_feedurl, query => { %{$args || {}}, exportFormat => $format, }, } ); if ($res->is_success) { if ( $file ) { my $content = $res->content_ref; return write_file( $file, {binmode => ':raw'}, $content ); } return $res->decoded_content; } } 1; __END__