You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by se...@apache.org on 2019/05/04 10:06:02 UTC
[commons-net] branch master updated: NET-646 ALLO FTP Command for
files >2GB
This is an automated email from the ASF dual-hosted git repository.
sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-net.git
The following commit(s) were added to refs/heads/master by this push:
new 39f8fa7 NET-646 ALLO FTP Command for files >2GB
39f8fa7 is described below
commit 39f8fa7a1e8386edc05d924932733ea2f9b5fc6a
Author: Sebb <se...@apache.org>
AuthorDate: Sat May 4 11:05:53 2019 +0100
NET-646 ALLO FTP Command for files >2GB
---
src/changes/changes.xml | 3 ++
src/main/java/org/apache/commons/net/ftp/FTP.java | 40 ++++++++++++++++++++++
.../java/org/apache/commons/net/ftp/FTPClient.java | 37 ++++++++++++++++++++
3 files changed, 80 insertions(+)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 8b480cb..5ad5d21 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -74,6 +74,9 @@ This is mainly a bug-fix release. See further details below.
The examples are not part of the public API, so this does not affect compatibility.
">
+ <action issue="NET-646" type="add" dev="sebb">
+ ALLO FTP Command for files >2GB
+ </action>
<action issue="NET-615" type="add" dev="sebb">
IMAPClient could simplify using empty arguments
</action>
diff --git a/src/main/java/org/apache/commons/net/ftp/FTP.java b/src/main/java/org/apache/commons/net/ftp/FTP.java
index e116110..2bb2552 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTP.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTP.java
@@ -1293,6 +1293,25 @@ public class FTP extends SocketClient
return sendCommand(FTPCmd.ALLO, Integer.toString(bytes));
}
+ /***
+ * A convenience method to send the FTP ALLO command to the server,
+ * receive the reply, and return the reply code.
+ *
+ * @param bytes The number of bytes to allocate.
+ * @return The reply code received from the server.
+ * @throws 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.
+ * @throws IOException If an I/O error occurs while either sending the
+ * command or receiving the server reply.
+ ***/
+ public int allo(long bytes) throws IOException
+ {
+ return sendCommand(FTPCmd.ALLO, Long.toString(bytes));
+ }
+
/**
* A convenience method to send the FTP FEAT command to the server, receive the reply,
* and return the reply code.
@@ -1328,6 +1347,27 @@ public class FTP extends SocketClient
}
/***
+ * A convenience method to send the FTP ALLO command to the server,
+ * receive the reply, and return the reply code.
+ *
+ * @param bytes The number of bytes to allocate.
+ * @param recordSize The size of a record.
+ * @return The reply code received from the server.
+ * @throws 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.
+ * @throws IOException If an I/O error occurs while either sending the
+ * command or receiving the server reply.
+ ***/
+ public int allo(long bytes, int recordSize) throws IOException
+ {
+ return sendCommand(FTPCmd.ALLO, Long.toString(bytes) + " R " +
+ Integer.toString(recordSize));
+ }
+
+ /***
* A convenience method to send the FTP REST command to the server,
* receive the reply, and return the reply code.
*
diff --git a/src/main/java/org/apache/commons/net/ftp/FTPClient.java b/src/main/java/org/apache/commons/net/ftp/FTPClient.java
index 9b9c260..704dc32 100644
--- a/src/main/java/org/apache/commons/net/ftp/FTPClient.java
+++ b/src/main/java/org/apache/commons/net/ftp/FTPClient.java
@@ -2280,6 +2280,24 @@ implements Configurable
}
/**
+ * Reserve a number of bytes on the server for the next file transfer.
+ *
+ * @param bytes The number of bytes which the server should allocate.
+ * @return True if successfully completed, false if not.
+ * @throws 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.
+ * @throws IOException If an I/O error occurs while either sending a
+ * command to the server or receiving a reply from the server.
+ */
+ public boolean allocate(long bytes) throws IOException
+ {
+ return FTPReply.isPositiveCompletion(allo(bytes));
+ }
+
+ /**
* Query the server for supported features. The server may reply with a list of server-supported exensions.
* For example, a typical client-server interaction might be (from RFC 2389):
* <pre>
@@ -2446,6 +2464,25 @@ implements Configurable
return FTPReply.isPositiveCompletion(allo(bytes, recordSize));
}
+ /**
+ * Reserve space on the server for the next file transfer.
+ *
+ * @param bytes The number of bytes which the server should allocate.
+ * @param recordSize The size of a file record.
+ * @return True if successfully completed, false if not.
+ * @throws 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.
+ * @throws IOException If an I/O error occurs while either sending a
+ * command to the server or receiving a reply from the server.
+ */
+ public boolean allocate(long bytes, int recordSize) throws IOException
+ {
+ return FTPReply.isPositiveCompletion(allo(bytes, recordSize));
+ }
+
/**
* Issue a command and wait for the reply.