Last active
August 29, 2015 14:27
-
-
Save allanon/0246e685b81ebf22bffa to your computer and use it in GitHub Desktop.
test kaltura ftp uploads
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use Disney::Util; | |
# Force dev environment. We don't want to accidentally run tests on production! | |
$ENV{DOLX_ENVIRONMENT} = 'development'; | |
my $opt = Disney::Util::get_dolx_options( {}, {} ); | |
my $conf = Disney::Util::load_and_merge_conf( $opt ); | |
if ( $conf->{ftp_logins}->{kaltura}->{username} ne 'drpftp4' ) { | |
print "Unable to run tests. FTP username is [$conf->{ftp_logins}->{kaltura}->{username}] and should be [drpftp4].\n"; | |
exit; | |
} | |
# Create the test file. | |
open FP, '>', '/tmp/test_file.txt'; | |
print FP join "\n", map { | |
join ' ', map { int $$ } 0 .. 12 | |
} 0 .. 100; | |
close FP; | |
my ( $ftp, $file ); | |
$ftp = Net::FTP->new( 'ftp.kaltura.com' ); | |
$ftp->debug( 1 ); | |
$ftp->login( 'drpftp4', $conf->{ftp_logins}->{kaltura}->{password} ) || die $!; | |
$ftp->binary || die $!; | |
$ftp->pasv; | |
$ftp->put( '/tmp/test_file.txt' => ( $file = "test_file.txt.$$." . __LINE__ ) ) || die $!; | |
printf "Created file %s with size %d\n", $file, $ftp->size( $file ) || -1; | |
$ftp->quit; | |
$ftp = Net::FTP::AutoReconnect->new( 'ftp.kaltura.com' ); | |
$ftp->{ftp}->debug( 1 ); # Net::FTP::AutoReconnect doesn't proxy this method. | |
$ftp->login( 'drpftp4', $conf->{ftp_logins}->{kaltura}->{password} ) || die $!; | |
$ftp->binary || die $!; | |
$ftp->pasv; | |
$ftp->put( '/tmp/test_file.txt' => ( $file = "test_file.txt.$$." . __LINE__ ) ) || die $!; | |
printf "Created file %s with size %d\n", $file, $ftp->size( $file ) || -1; | |
$ftp->quit; | |
$ftp = Disney::Util::ftp_connect( $conf->{ftp_logins}, 'kaltura' ); | |
$ftp->{ftp}->debug( 1 ); # Net::FTP::AutoReconnect doesn't proxy this method. | |
$ftp->pasv; | |
$ftp->put( '/tmp/test_file.txt' => ( $file = "test_file.txt.$$." . __LINE__ ) ) || die $!; | |
printf "Created file %s with size %d\n", $file, $ftp->size( $file ) || -1; | |
$ftp->quit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment