Class FTPRemoteFile

    • Field Detail

      • FTP_RETRIES

        public static int FTP_RETRIES
        How many times we will retry upload, download, and logon.
      • FTP_DATATIMEOUT

        public static int FTP_DATATIMEOUT
        How large a data timeout on our FTP connections.
      • checksum

        protected final String checksum
        If useChecksums is true, contains the file checksum.
    • Method Detail

      • getInstance

        public static RemoteFile getInstance​(File localFile,
                                             Boolean useChecksums,
                                             Boolean fileDeletable,
                                             Boolean multipleDownloads)
                                      throws IOFailure
        Create a remote file that handles the transport of the remote file data. This method is used by the sender to prepare the transport.
        Parameters:
        localFile - File object for the remote file
        useChecksums - If true, checksums will be used to check transfers.
        fileDeletable - If true, this file will be deleted after upload to FTP.
        multipleDownloads - If true, the file will not be removed from FTP server automatically after first download.
        Returns:
        FTPRemoteFile object
        Throws:
        IOFailure - if FTPRemoteFile creation fails
      • getInputStream

        public InputStream getInputStream()
        An implementation of the getInputStream operation that works with FTP. Notice that most of the special work (logging out and checking MD5) happens in the close() method of the returned InputStream, since that is the only place where we can know we're done.
        Specified by:
        getInputStream in interface RemoteFile
        Specified by:
        getInputStream in class AbstractRemoteFile
        Returns:
        An InputStream that will deliver the data transferred by FTP. Holding on to this for long periods without reading any data might cause a timeout.
      • appendTo

        public void appendTo​(OutputStream out)
        Write the contents of this ftp remote file to an output stream. Notice that while the checksum of the transferred data is checked, no retries are performed, and in case of failure, there is no guarantee that any data have been transferred.
        Specified by:
        appendTo in interface RemoteFile
        Overrides:
        appendTo in class AbstractRemoteFile
        Parameters:
        out - OutputStream that the data will be written to. This stream will not be closed by this operation.
        Throws:
        IOFailure - If append operation fails
      • cleanup

        public void cleanup()
        Cleanup will delete the file on the FTP server. This method should never throw exceptions. It is idempotent, meaning it can be called twice without trouble.
        Specified by:
        cleanup in interface RemoteFile
        Specified by:
        cleanup in class AbstractRemoteFile
      • toString

        public String toString()
        Return a human-readable description of the object.
        Overrides:
        toString in class AbstractRemoteFile
        Returns:
        description of object -- not machine readable
      • getChecksum

        public String getChecksum()
        Get checksum for file, or null if checksums were not requested.
        Specified by:
        getChecksum in interface RemoteFile
        Specified by:
        getChecksum in class AbstractRemoteFile
        Returns:
        checksum for file, or null if checksums were not requested.
      • getNumberOfRetries

        public int getNumberOfRetries()
        Retrieval of the number of retries for retrieving a file from a FTP server. Returns the setting for number of retries.
        Specified by:
        getNumberOfRetries in class AbstractRemoteFile
        Returns:
        The number of retries for the FTP connection, defined in settings.