NAME

Net::SFTP::Foreign::Tempdir::Extract - Secure FTP client integrating Path::Class, Tempdir, and Archive Extraction

SYNOPSIS

use Net::SFTP::Foreign::Tempdir::Extract;
my $sftp=Net::SFTP::Foreign::Tempdir::Extract->new(
                         user   => $user,
                         match  => qr/\.zip\Z/,
                         backup => "./backup", #default is not to backup
                         delete => 1,          #default is not to delete
                        );
my $file=$sftp->next;

DESCRIPTION

Secure FTP client which downloads files locally to a temp directory for operations and automatically cleans up all temp files after variables are out of scope.

USAGE

File Downloader

This is a simple file downloader implementation

use Net::SFTP::Foreign::Tempdir::Extract;
my $sftp=Net::SFTP::Foreign::Tempdir::Extract->new(host=>$host, user=>$user);
my $file=$sftp->download($folder, $filename);

File Watcher

This is a simple file watcher implementation

use Net::SFTP::Foreign::Tempdir::Extract;
my $sftp=Net::SFTP::Foreign::Tempdir::Extract->new(host=>"myserver", user=>"myaccount", match=>qr/\.zip\Z/, folder=>"/myfolder");
my $file=$sftp->next or exit; #nothing to process so exit
print "$file";                #process file here

Subclass

This is a typical subclass implementation for a particular infrastructure

package My::SFTP;
use base qw{Net::SFTP::Foreign::Tempdir::Extract};
sub host   {"myserver.mydomain.tld"};
sub folder {"/myfolder"};
sub match  {qr/\Amyfile\.zip\Z/};
sub backup {time};
sub delete (1);
1;

CONSTRUCTOR

new

METHODS

download

Downloads the named file in the folder.

my $file=$sftp->download("remote_file.zip");                   #isa Net::SFTP::Foreign::Tempdir::Extract::File
my $file=$sftp->download("/remote_folder", "remote_file.zip"); #  which isa Path::Class::File object with an extract method

next

Downloads the next file in list and saves it locally to a temporary folder. Returns a Path::Class::File object or undef if there are no more files.

list

Returns list of filenames that match the folder and regular expression

Note: List is shifted for each call to next method

PROPERTIES

host

SFTP server host name.

user

SFTP user name (defaults to current user)

folder

Folder on remote SFTP server.

Note: Some SFTP servers put clients in a change rooted environment.

match

Regular Expression to match file names for the next iterator

backup

Sets or returns the backup folder property.

delete

Sets or returns the delete boolean property.

OBJECT ACCESSORS

sftp

Returns a cached connected Net::SFTP::Foreign object

BUGS

Send email to author and log on RT.

SUPPORT

DavisNetworks.com supports all Perl applications including this package.

AUTHOR

Michael R. Davis
CPAN ID: MRDVT
Satellite Tracking of People, LLC
mdavis@stopllc.com
http://www.stopllc.com/

COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO

Building Blocks

Path::Class::File, Net::SFTP::Foreign, File::Tempdir