GithubHelp home page GithubHelp logo

perl-mailru-cloud-api's Introduction

NAME

Mailru::Cloud - Simple REST API cloud mail.ru client

VERSION

version 0.02

SYNOPSYS

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',
                        );

METHODS

login(%opt)

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

info()

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";

uploadFile(%opt)

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";

downloadFile(%opt)

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

createFolder(%opt)

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

deleteResource(%opt)

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

emptyTrash()

Empty trash on cloud.mail.ru. Return 1 if success. Die on error

$cloud->emptyTrash();

listFiles(%opt)

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
},
]

shareResource(%opt)

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

DEPENDENCE

LWP::UserAgent, JSON::XS, URI::Escape, IO::Socket::SSL, Encode, HTTP::Request, Carp, File::Basename

AUTHORS

COPYRIGHT AND LICENSE

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.

perl-mailru-cloud-api's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.