Net::API::Gett - Perl bindings for Ge.tt API
Version 1.06
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 => 'me@example.com', 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.
Net::API::Gett::User object. has_user() predicate.
has_user()
Net::API::Gett::Request object.
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: get_share(), get_file(), $file->thumbnail() and $file->contents().
get_share()
get_file()
$file->thumbnail()
$file->contents()
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.
shares
get_share
Retrieves all share information for the given user. Takes optional scalar integers offset and limit parameters, respectively.
offset
limit
Returns an unordered list of Net::API::Gett::Share objects.
Retrieves (and/or refreshes cached) information about a specific single share. Requires a sharename parameter. Does not require an access token to call.
sharename
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 sharename and a fileid. Does not require an access token to call.
fileid
This method uploads a file to Gett. The following key/value pairs are valid:
filename (required)
What to call the uploaded file when it's inside of the Gett service.
sharename (optional)
Where to store the uploaded file. If not specified, a new share will be automatically created.
title (optional)
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.
update()
content (optional)
A synonym for contents. (Yes, I've typo'd this too many times.) Anything in contents has precedent, if they're both specified.
contents
contents (optional)
A representation of the file's contents. This can be one of:
A buffer (See note below)
An IO::Handle object
A FILEGLOB
A pathname to a file to be read
If not specified, the filename parameter is treated as a pathname. This attempts to be DWIM, in the sense that if contents contains a value which is not a valid filename, it treats contents as a buffer and uploads that data.
filename
encoding
An encoding scheme for the file content. By default it uses :raw. See perldoc -f binmode for more information about encodings.
:raw
perldoc -f binmode
chunk_size
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.
Mark Allen, <mrallen1 at yahoo dot com>
<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.
bug-net-api-gett at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Net::API::Gett
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net-API-Gett
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Net-API-Gett
CPAN Ratings
http://cpanratings.perl.org/d/Net-API-Gett
MetaCPAN
https://metacpan.org/module/Net::API::Gett/
GitHub
https://github.com/mrallen1/Net-API-Gett
Gett API documentation
Thanks to the following for patches:
Keedi Kim (https://github.com/keedi)
Alexander Ost
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.
To install Net::API::Gett, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::API::Gett
CPAN shell
perl -MCPAN -e shell install Net::API::Gett
For more information on module installation, please visit the detailed CPAN module installation guide.