NAME

Mega::Cli - simple wrapper for Mega.nz cli

VERSION

version 0.01

SYNOPSIS

This module use to upload, download, share file from Mega account. Module work only exclusively use Mega::Cli;

#Create mega object
my $mega = Mega::Cli->new(
    -path       => '/usr/bin',
);

#Login to mega
$mega->login(
    -login      => $mega_login,
    -password   => $mega_password,
);

#Upload file
my $local_file = '/tmp/test_file.txt';
my $remote_file = '/tmp/cloud/test_file.txt';
$mega->uploadFile(
    -local_file         => $local_file,
    -remote_file        => $remote_file,
    -create_dir         => 1,
);

#Download file
$mega->downloadFile(
        -local_file     => $local_file,
        -remote_file    => $remote_file,
);

#Share file
my $share_link = $mega->shareResource($remote_file);

METHODS

new(%opt)

Create Mega::Cli object

%opt:
    -path       => Path to mega cmd (default: /usr/bin)
    -lock_port  => Port to exclusively lock (default: 50000)

login(%opt)

Login to mega account. Return 1 if success, die in otherwise

%opt:
    -login      => Login from mega.nz
    -password   => Password from mega.nz

logout()

Logout from mega account

uploadFile(%opt)

Upload file from local disk to mega cloud. Return 1 if success, die in otherwise

%opt:
   -local_file          => Full path to source file on local disk
   -remote_file         => Full path to remote file on cloud 
   -create_dir          => Create dir on cloud if dir not exists (default: 0)

downloadFile(%opt)

Download file from mega cloud to local disk. Return 1 if success, die in otherwise

%opt:
   -local_file          => Full path to source file on local disk
   -remote_file         => Full path to remote file on cloud 

createDir(%opt)

Create dir on mega cloud

%opt:
    -dir                => Dir name to create on mega cloud

shareResource(%opt)

Share resource (file/folder) and get url to download resource. Return share link if success, die in otherwise

%opt:
    -remote_resource    => Full path to remote resource to share

unshareResource(%opt)

Unshare resource (file/folder). Return 1 if success, die in otherwise

%opt:
    -remote_resource    => Full path to remote resource to unshare

DEPENDENCE

File::Spec, Lock::Socket

AUTHORS

  • Pavel Andryushin <vrag867@gmail.com>

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.