>>  how can I identify partially uploaded files on the server?

There is no such term as "partially uploaded" when a file is copied via
SFTP to a server. The server is not told ahead of time how much data to
expect - the client simply opens a file (for write) and writes data at
successive offsets. If the client was supposed to write K bytes but decided
after N < K bytes to stop writing and close the file handle, there is no
way I can think of that the server can tell that the file is "incomplete".

The only thing the server can  tell is whether the file handle was
"aborted" - i.e., closed in some abnormal way. This may indicate that file
copy was somehow aborted and thus "incomplete" - but only in the sense that
the transfer was interrupted.

If you wish to be 100% sure that files are fully uploaded use SCP and not
SFTP. In SCP, the server is told how much data to expect and the client
must sent that exact amount of data or the server declare the upload
"incomplete" and returns an error.

Either way, you can monitor both SCP and SFTP by registering the
appropriate Sftp/ScpEventListener(s) and handling the reported events.

>>  how to identify if client network is disconnected?

It depends on what you mean by that - if you want to query the session if
it is connected before sending some packet, then you can ask isOpen(). Note
though that this does not really mean that client/server is connected. It
only means that as far as the code knows the session *seems* open -
however, there are no guarantees that it is indeed open as it depends on
the peer.The peer may be down but we have not detected this fact yet.

If you want to track connect/disconnect somehow  I  recommend registering a
SessionListener and then use a custom attribute to mark  the session's
connect/disconnect state. Note (again) that it does not guarantee anything
- just that as far as the listener is concerned it has not detected a
problem/disconnect.

Reply via email to