Mailru::Cloud - Simple REST API cloud mail.ru client
version 0.02
use Mailru::Cloud;
my $cloud = Mailru::Cloud->new;
#Authorize on cloud.mail.ru
$cloud->login(-login => 'test', -password => '12345') or die "Cant login on mail.ru";
#Upload file Temp.png to folder /folder on cloud.mail.ru
my $uploaded_name = $cloud->uploadFile(
-file => 'Temp.png', # Path to file on localhost
-path => '/folder', # Path on cloud.
-rename => 1, # Rename file if exists (default: overwrite exists file)
);
#Download file from cloud
$cloud->downloadFile(
-cloud_file => '/folder/Temp.png',
-file => 'Temp.png',
);
Login on cloud.mail.ru server.Return csrf token if success. Die on error
$cloud->login(-login => 'test', -password => '12345');
Options:
-login => login form cloud.mail.ru
-password => password from cloud.mail.ru
Return hashref to info with keys: used_space, total_space, file_size_limit
my $info = $cloud->info() || die "Can't get info";
print "Used_space: $info->{used_space}\nTotal space: $info->{total_space}\nFile size limit: $info->{file_size_limit}\n";
Upload local file to cloud. Return full file name on cloud if success. Die on error
my $uploaded_name = $cloud->uploadFile(-file => 'Temp.png');
Options:
-file => Path to local file
-path => Folder on cloud
-rename => Rename file if exists (default: overwrite exists file)
Get Mailru cloud hash of uploaded file
my $hash = $cloud->get_last_uploaded_file_hash() || die "Can't get file hash";
Download file from cloud.mail.ru to local file. Method overwrites local file if exists. Return full file name on local disk if success. Die if error
my $local_file = $cloud->downloadFile(-cloud_file => '/Temp/test', -file => 'test');
Options:
-cloud_file => Path to file on cloud.mail.ru
-file => Path to local destination
Create recursive folder on cloud.mail.ru. Return 1 if success, undef if folder exists. Die on error
$cloud->creteFolder(-folder => '/Temp/test');
Options:
-folder => Path to folder on cloud
Delete file/folder from cloud.mail.ru. Resource moved to trash. To delete run emptyTrash() method. Return 1 if success. Die on error
$cloud->deleteResource(-path => '/Temp/test.txt'); #Delete file '/Temp/test.txt' from cloud
Options:
-path => Path to delete resource
Empty trash on cloud.mail.ru. Return 1 if success. Die on error
$cloud->emptyTrash();
Return struct (arrayref) of files and folders. Die on error
my $list = $cloud->listFiles(-path => '/'); #Get list files and folder in path '/'
Options:
-path => Path to get file list (default: '/')
Example output:
[
{
type => 'folder', # Type file/folder
name => 'Temp', # Name of resource
size => 12221, # Size in bytes
weblink => 'https://cloud.mail.ru/public/4L8/K343', # Weblink to resource, if resource shared
},
]
Share resource for all. Return weblink if success. Die if error
my $link = $cloud->shareResource(-path => '/Temp/'); Share folder /Temp
Options:
-path => Path to shared resource
LWP::UserAgent, JSON::XS, URI::Escape, IO::Socket::SSL, Encode, HTTP::Request, Carp, File::Basename
- Pavel Andryushin [email protected]
This software is copyright (c) 2018 by Pavel Andryushin.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.