Example usage for org.apache.commons.net.ftp FTPCmd STOR

List of usage examples for org.apache.commons.net.ftp FTPCmd STOR

Introduction

In this page you can find the example usage for org.apache.commons.net.ftp FTPCmd STOR.

Prototype

FTPCmd STOR

To view the source code for org.apache.commons.net.ftp FTPCmd STOR.

Click Source Link

Usage

From source file:com.adaptris.ftp.ApacheFtpClientImpl.java

@Override
public void put(InputStream srcStream, String remoteFile, boolean append) throws IOException {
    try {/*from w  ww  .  ja  v a2s.c  o  m*/
        acquireLock();
        if (append) {
            log("{} {}", FTPCmd.APPE, remoteFile);
            handleReturnValue(ftpClient().appendFile(remoteFile, srcStream));
        } else {
            log("{} {}", FTPCmd.STOR, remoteFile);
            handleReturnValue(ftpClient().storeFile(remoteFile, srcStream));
        }
    } finally {
        logReply(ftpClient().getReplyStrings());
        releaseLock();
    }
}

From source file:ch.cyberduck.core.ftp.FTPClient.java

@Override
public boolean storeFile(String remote, InputStream local) throws IOException {
    this.pret(FTPCmd.STOR, remote);
    return super.storeFile(remote, local);
}

From source file:ch.cyberduck.core.ftp.FTPClient.java

@Override
public OutputStream storeFileStream(String remote) throws IOException {
    this.pret(FTPCmd.STOR, remote);
    return super.storeFileStream(remote);
}

From source file:com.atomicleopard.thundr.ftp.commons.FTP.java

/***
 * A convenience method to send the FTP STOR command to the server,
 * receive the reply, and return the reply code.  Remember, it is up
 * to you to manage the data connection.  If you don't need this low
 * level of access, use {@link org.apache.commons.net.ftp.FTPClient}
 * , which will handle all low level details for you.
 * <p>/*from w ww.j  a  v a 2s.c o m*/
 * @param pathname  The pathname to use for the file when stored at
 *                  the remote end of the transfer.
 * @return The reply code received from the server.
 * @exception FTPConnectionClosedException
 *      If the FTP server prematurely closes the connection as a result
 *      of the client being idle or some other reason causing the server
 *      to send FTP reply code 421.  This exception may be caught either
 *      as an IOException or independently as itself.
 * @exception IOException  If an I/O error occurs while either sending the
 *      command or receiving the server reply.
 ***/
public int stor(String pathname) throws IOException {
    return sendCommand(FTPCmd.STOR, pathname);
}

From source file:com.atomicleopard.thundr.ftp.commons.FTPClient.java

/**
 * Stores a file on the server using the given name and taking input
 * from the given InputStream.  This method does NOT close the given
 * InputStream.  If the current file type is ASCII, line separators in
 * the file are transparently converted to the NETASCII format (i.e.,
 * you should not attempt to create a special InputStream to do this).
 * <p>// w w w . j  a  v  a  2s. co m
 * @param remote  The name to give the remote file.
 * @param local   The local InputStream from which to read the file.
 * @return True if successfully completed, false if not.
 * @exception FTPConnectionClosedException
 *      If the FTP server prematurely closes the connection as a result
 *      of the client being idle or some other reason causing the server
 *      to send FTP reply code 421.  This exception may be caught either
 *      as an IOException or independently as itself.
 * @exception org.apache.commons.net.io.CopyStreamException
 *      If an I/O error occurs while actually
 *      transferring the file.  The CopyStreamException allows you to
 *      determine the number of bytes transferred and the IOException
 *      causing the error.  This exception may be caught either
 *      as an IOException or independently as itself.
 * @exception IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 */
public boolean storeFile(String remote, InputStream local) throws IOException {
    return __storeFile(FTPCmd.STOR, remote, local);
}

From source file:com.atomicleopard.thundr.ftp.commons.FTPClient.java

/**
 * Returns an OutputStream through which data can be written to store
 * a file on the server using the given name.  If the current file type
 * is ASCII, the returned OutputStream will convert line separators in
 * the file to the NETASCII format  (i.e., you should not attempt to
 * create a special OutputStream to do this).  You must close the
 * OutputStream when you finish writing to it.  The OutputStream itself
 * will take care of closing the parent data connection socket upon being
 * closed.  To finalize the file transfer you must call
 * {@link #completePendingCommand  completePendingCommand } and
 * check its return value to verify success.
 * <p>// www.  ja v a2  s .c o  m
 * @param remote  The name to give the remote file.
 * @return An OutputStream through which the remote file can be written.  If
 *      the data connection cannot be opened (e.g., the file does not
 *      exist), null is returned (in which case you may check the reply
 *      code to determine the exact reason for failure).
 * @exception FTPConnectionClosedException
 *      If the FTP server prematurely closes the connection as a result
 *      of the client being idle or some other reason causing the server
 *      to send FTP reply code 421.  This exception may be caught either
 *      as an IOException or independently as itself.
 * @exception IOException  If an I/O error occurs while either sending a
 *      command to the server or receiving a reply from the server.
 */
public OutputStream storeFileStream(String remote) throws IOException {
    return __storeFileStream(FTPCmd.STOR, remote);
}