0

Is there a way to get the file size on a TFTP server without downloading the file. I want an JAVA API for the same if available.

I tried TFTPClient, but it does not support.

Note: I am able to get the file size on local tftp server, but not on the remote tftp. For the local below code works:

DatagramSocket socket = new DatagramSocket();
SocketAddress sockAddr = new InetSocketAddress(address.getHostAddress(),
                                               portNumber);
socket.connect(sockAddr);
File file = new File(fileName);
long fileSize = getFileSize(file);
if (fileSize > 0) {
    return fileSize;
}
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
user2503105
  • 21
  • 1
  • 3

1 Answers1

1

The TFTP protocol (as specified in RFC 1350) does not support this.

Note that RFC 1350 has been enhanced with the ability to negotiate options; see the "updated by" list in the RFC. However none of these updates provide a way to request the file size.

So the answer is that there is no way using a compliant TFTP server.

Community
  • 1
  • 1
Stephen C
  • 698,415
  • 94
  • 811
  • 1,216