NET-646 ALLO FTP Command for files >2GB
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 @@
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 @@
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 @@
}
/***
+ * 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 @@
}
/**
+ * 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 @@
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.