Net::MeoCloud - A MEO Cloud interface
Version 0.01
This module is a Perl interface to the API for the Portuguese cloud storage service MEO Cloud. You can learn more about it at http://www.meocloud.pt.
Quick start:
use Net::MeoCloud;
my $cloud = Net::MeoCloud->new( key => 'KEY', secret => 'SECRET' );
$cloud->login;
# the user manually authorizes the app, retrieving the verifier PIN...
$cloud->authorize( verifier => $pin );
my $response = $cloud->share( path => '/Photos/logo.png' );
my $data = $cloud->get_file( path => '/Photos/logo.png' );
The particular details regarding the API can be found at https://meocloud.pt/documentation
Create a new Net::MeoCloud
object. The key
and secret
parameters are required.
Perform the initial login operation, identifying the client on the service.
If the handshake is successful, a request token/secret is obtained which allows an authorization URL to be returned. This URL must be opened by the user to explicitly authorize access to the service's account.
Furthermore, MEO Cloud then either redirects the user back to the callback URL
(if defined in $self->{callback_url}
), or openly provides a PIN number
that will be required to verify that the user's authorization is valid.
This method exchanges the request token/secret, obtained after a successful login, with an access token/secret that is needed for subsequent accesses to the service's API.
The verifier
PIN parameter is required.
This method returns a boolean answer regarding the authorization status of the current credentials.
$boolean = $cloud->is_authorized;
Shows information about the user.
$data = $cloud->account_info;
Returns all the metadata available for a given file or folder (specified
through its path
).
$metadata = $cloud->metadata( path => '/Photos' );
Returns the metadata of a shared resource. Its share id
and name
are
required.
$data = $cloud->metada_share(
share_id => 'a1bc7534-3786-40f1-b435-6fv90a00b2a6', name => 'logo.png'
);
Returns a list of all the public links created by the user.
$data = $cloud->list_links;
Delete a public link of a file or folder. Its share id
is required.
$response = $cloud->delete_link( id => 'a1bc7534-3786-40f1-b435-6fv90a00b2a6' );
Create a public link of a file or folder. Its path
is required.
$response = $cloud->share( path => '/Photos/logo.png' );
Share a folder with another user. The folder's path
, and a target email
are required.
$response = $cloud->share_folder(
path => '/Photos', email => 'friend@home.com'
);
Returns a list of all the shared folders accessed by the user.
$data = $cloud->list_shared_folders;
Returns metadata for a given file or folder (specified through its path
).
Similar to the actual metadata
method, but with less items and more options.
$metadata = $cloud->list( path => '/Photos' );
Return the thumbnail (in binary format) of the file specified in the path
.
$content = $cloud->thumbnail( path => '/Photos/logo.png' );
Search the path
for a file, or folder, that matches the given query
.
$content = $cloud->search( path => '/Photos' query => 'logo.png' );
Obtain information of the most recent version on the file in the path
.
$content = $cloud->search( path => '/Photos/logo.png' );
Restore a specific revision
of the file in the path
.
$response = $cloud->restore(
path => '/Photos/logo.png',
revision => '384186e2-31e9-11e2-927c-e0db5501ca40'
);
Return a direct link for the file in the path
. If it's a video/audio file, a
streaming link is returned per the protocol
parameter.
$response = $cloud->media( path => '/Music/song.mp3', protocol => 'rtsp' );
List the current changes available for syncing.
$data = $cloud->delta;
Upload a file to MEO Cloud.
You can choose to overwrite
it (this being either true
or false
), if
it already exists, as well as choose to overwrite a parent_rev
of the file.
$response = $cloud->put_file( file => 'logo2.png', path => '/Photos' );
Download a file from MEO Cloud. A specific rev
can be requested.
$data = $cloud->get_file( path => '/Photos/logo2.png' );
From a file in from_path
, create a copy in to_path
.
Alternatively, instead of from_path
, a copy from a file reference can be
done with from_copy_ref
. The reference is generated from a previous call to
copy_ref
.
$response = $cloud->copy(
from_path => '/Photos/logo2.png', to_path => '/Music/cover.png'
);
Creates, and returns, a copy reference to the file in path
.
This can be used to copy that file to another user's MEO Cloud.
$response = $cloud->copy_ref( path => '/Music/cover.png' );
Take a file in from_path
, and move it into to_path
.
$response = $cloud->move(
from_path => '/Photos/logo2.png', to_path => '/Music/cover.png'
);
Create a folder in path
.
$response = $cloud->create_folder( path => '/Music/Rock' );
Delete a file in path
.
$response = $cloud->delete( path => '/Music/cover.png' );
Undelete a file, or folder, previously removed.
$response = $cloud->undelete( path => '/Music/cover.png' );
Return the most recent error message. If the last API request was completed successfully, this method will return an empty string.
Generate a unique 'nonce' to be used on each request.
Execute a particular API request to the service's protected resources.
Sérgio Bernardino, <code@sergiobernardino.net>
Copyright 2013 Sérgio Bernardino.
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.