<% include( '/elements/header.html', 'Developer Documentation' ) %> <& /elements/menubar.html, 'Freeside Perl Modules' => $fsurl.'docs/library/FS.html', 'Complete Index' => $fsurl.'docs/library/index.html', &>

FS::upload_target

NAME

FS::upload_target - Object methods for upload_target records

SYNOPSIS

  use FS::upload_target;

  $record = new FS::upload_target \%hash;
  $record = new FS::upload_target { 'column' => 'value' };

  $error = $record->insert;

  $error = $new_record->replace($old_record);

  $error = $record->delete;

  $error = $record->check;

DESCRIPTION

An FS::upload_target object represents a destination to deliver files (such as invoice batches) by FTP, SFTP, or email. FS::upload_target inherits from FS::Record.

targetnum - primary key
agentnum - FS::agent foreign key; can be null
protocol - 'ftp', 'sftp', or 'email'.
hostname - the DNS name of the FTP site, or the domain name of the email address.
port - the TCP port number, if it's not standard.
username - username
password - password
path - for FTP/SFTP, the working directory to change to upon connecting.
subject - for email, the Subject: header
handling - a string naming an additional process to apply to the file before sending it.

METHODS

new HASHREF

Creates a new FTP target. To add it to the database, see "insert".

insert

Adds this record to the database. If there is an error, returns the error, otherwise returns false.

delete

Delete this record from the database.

replace OLD_RECORD

Replaces the OLD_RECORD with this one in the database. If there is an error, returns the error, otherwise returns false.

check

Checks all fields to make sure this is a valid example. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods.

put LOCALNAME [ REMOTENAME ]

Uploads the file named LOCALNAME, optionally changing its name to REMOTENAME on the target. For FTP/SFTP, this opens a connection, changes to the working directory (path), and PUTs the file. For email, it composes an empty message and attaches the file.

Returns an error message if anything goes wrong.

connect

Creates a Net::FTP or Net::SFTP::Foreign object (according to the setting of the 'secure' flag), connects to 'hostname', attempts to log in with 'username' and 'password', and changes the working directory to 'path'. On success, returns the object. On failure, dies with an error message.

Always returns an error for email targets.

label

Returns a descriptive label for this target.

handling_types

Returns a list of values for the "handling" field, corresponding to the known ways to preprocess a file before uploading. Currently those are implemented somewhat crudely in FS::Cron::upload.

BUGS

Handling methods should be here, but instead are in FS::Cron.

SEE ALSO

FS::Record, schema.html from the base documentation.

<% include ('/elements/footer.html' ) %>