- CHANGES FROM PREVIOUS VERSION
- SEE ALSO
- LICENSE AND COPYRIGHT
Net::API::Gett - Perl bindings for Ge.tt API
use 5.010; use Net::API::Gett; # Get API Key from http://ge.tt/developers my $gett = Net::API::Gett->new( api_key => 'GettAPIKey', email => 'firstname.lastname@example.org', password => 'mysecret', ); my $file_obj = $gett->upload_file( filename => "ossm.txt", contents => "/some/path/example.txt", title => "My Awesome File", encoding => ":encoding(UTF-8)" ); say "File has been shared at " . $file_obj->getturl; # Download contents my $file_contents = $file_obj->contents(); open my $fh, ">:encoding(UTF-8)", "/some/path/example-copy.txt" or die $!; print $fh $file_contents; close $fh; # clean up share and file(s) my $share = $gett->get_share($file->sharename); $share->destroy();
Gett is a clutter-free file sharing service that allows its users to share up to 2 GB of files for free. They recently implemented a REST API; this is a binding for the API. See http://ge.tt/developers for full details and how to get an API key.
This library is more encapsulated. Share functions which act on shares are in the Net::API::Gett::Share object namespace, and likewise with Ge.tt files. Future versions of this library will modify the Request and User objects to be roles rather than objects.
Unless otherwise noted, these methods die if an error occurs or if they get a response from the API which is not successful. If you need to handle errors more gracefully, use Try::Tiny to catch fatal errors.
Constructs a new object. Optionally accepts:
A Ge.tt API key, email, and password, or,
A Ge.tt refresh token, or,
A Ge.tt access token
If any of these parameters are passed, they will be proxied into the Net::API::Gett::User object which will then permit you to make authenticated API calls. Without an access token (or the means to acquire one) only non-authenticated calls are allowed; they are:
All of these functions cache Net::API::Gett::Share objects. Retrieve objects from the cache using the
shares method. Use the
get_share method to update a cache entry if it is stale.
Retrieves all share information for the given user. Takes optional scalar integers
Returns an unordered list of Net::API::Gett::Share objects.
Retrieves (and/or refreshes cached) information about a specific single share. Requires a
sharenameparameter. Does not require an access token to call.
Returns a Net::API::Gett::Share object.
This method creates a new share instance to hold files. Takes an optional string scalar parameter which sets the share's title attribute.
Returns the new share as a Net::API::Gett::Share object.
Returns a Net::API::Gett::File object given a
fileid. Does not require an access token to call.
This method uploads a file to Gett. The following key/value pairs are valid:
What to call the uploaded file when it's inside of the Gett service.
Where to store the uploaded file. If not specified, a new share will be automatically created.
If specified, this value is used when creating a new share to hold the file. It will not change the title of an existing share. See the
update()method on the share object to do that.
A synonym for
contents. (Yes, I've typo'd this too many times.) Anything in
contentshas precedent, if they're both specified.
A representation of the file's contents. This can be one of:
A buffer (See note below)
An IO::Handle object
A pathname to a file to be read
If not specified, the
filenameparameter is treated as a pathname. This attempts to be DWIM, in the sense that if
contentscontains a value which is not a valid filename, it treats
contentsas a buffer and uploads that data.
An encoding scheme for the file content. By default it uses
perldoc -f binmodefor more information about encodings.
The chunk_size in bytes to use when uploading a file. Defaults to 1 MB.
Returns a Net::API::Gett:File object representing the uploaded file.
This method populates/updates the Net::API::Gett:Share object local cache.
It returns undef if the passed value isn't a Net::API::Gett::Share object.
This method retrieves one or more cached Net::API::Gett::Share objects. Objects are requested by sharename. If no parameter list is specified, all cached objects are returned in an unordered list. (The list will not be in the order shares were added to the cache.)
If no objects are cached, this method returns an empty list.
<mrallen1 at yahoo dot com>
Please report any bugs or feature requests to
bug-net-api-gett at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-API-Gett. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
Thanks to the following for patches:
Keedi Kim (https://github.com/keedi)
Copyright 2011 Mark Allen.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.