API-ISPManager
view release on metacpan or search on metacpan
lib/API/ISPManager/stat.pm
lib/API/ISPManager/user.pm
lib/API/ISPManager/vds.pm
lib/API/ISPManager/vdspreset.pm
Makefile.PL
MANIFEST This list of files
README
runtests.sh
t/01-test.t
t/02-files.t
upload_file.pl
vdsmanager.pl
META.yml Module meta-data (added by MakeMaker)
lib/API/ISPManager/file.pm view on Meta::CPAN
$API::ISPManager::last_answer = $result;
if ($result && $result->{ok}) {
return 1;
} else {
return '';
}
}
# Upload file
sub upload {
my $params = shift;
my $allowed_fields = [ qw( host path allow_http plid ) ];
my $func_name = 'file.upload';
my $auth_id = API::ISPManager::get_auth_id( %$params );
if ($auth_id) {
my $params_raw = API::ISPManager::filter_hash( $params, $allowed_fields );
my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)");
my $url = 'https://server8.hosting.reg.ru/mancgi/upload';
my $query_string = API::ISPManager::mk_full_query_string( {
( auth => $auth_id ),
func => $func_name,
%$params_raw,
} );
my $response = $ua->post(
'https://' . $params->{host} . '/mancgi/upload',
Content_Type => 'form-data',
Content => [
filename => [$params->{file}],
sok => 'ok',
auth => $auth_id,
plid => $params->{plid},
]
);
t/02-files.t view on Meta::CPAN
elid => "$now",
plid => '',
} );
# Çàãðóçêà ôàéëà
$now = time;
open my $fh, '>', $now or die "Can't open $now for writing: $!";
print {$fh} 'hello world';
close $fh;
my $upload_result = API::ISPManager::file::upload( {
%connection_params,
plid => '',
file => $now,
} );
@expected_file_list = @original_file_list;
push @expected_file_list, $now;
@real_file_list = get_file_list('', '');
ok(union_equal(\@expected_file_list, \@real_file_list), 'file upload');
API::ISPManager::file::delete( {
%connection_params,
elid => "$now",
plid => '',
} );
# Ðàñïàêîâêà àðõèâà
`tar -czf $now.tar.gz $now`;
API::ISPManager::file::upload( {
%connection_params,
plid => '',
file => "$now.tar.gz",
} );
my $extract_result = API::ISPManager::file::extract( {
%connection_params,
plid => '',
elid => "$now.tar.gz",
} );
upload_file.pl view on Meta::CPAN
$API::ISPManager::DEBUG = 1;
my %connection_params = (
username => $login,
password => $password,
host => $host,
path => 'manager',
);
my $upload_result = API::ISPManager::file::upload( {
%connection_params,
plid => $plid,
file => $filename,
} );
if ($upload_result) {
print "file success uploaded!\n";
} else {
warn Dumper($API::ISPManager::last_answer);
}
( run in 4.242 seconds using v1.01-cache-2.11-cpan-b16cb0d3907 )