Skip to content

Instantly share code, notes, and snippets.

@allanon
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allanon/0246e685b81ebf22bffa to your computer and use it in GitHub Desktop.
Save allanon/0246e685b81ebf22bffa to your computer and use it in GitHub Desktop.
test kaltura ftp uploads
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