Your server setup doesn't allow you to resume a broken file transfer and it's impossible for the client to verify if the file has been transferred correctly. Basically a setup like this is hardly usable outside of an experimental environment. The better way is to decrypt the files after they have been transferred (e.g. PGP) or the server should do everything transparently. It means the original file information (size) need to be returned by the server.