Reputation: 1305
I have a Java client/server desktop application, where the communication between client and server is based on Sockets, and the messages exchanged between client and server are serialized objects (message objects, that incapsulate requests and responses).
Now I need to make the client able to upload a file from the local computer to the server, but I can't send the File through the buffer, since the Buffer is already used for exchanging the message objects.
Should i open another stream to send the file, or is there any better way to upload a file for my situation?
Upvotes: 0
Views: 102
Reputation: 9086
You can keep your solution and pass the file content as an object, for example as a String - use Base64 encoding (or similar) of the content if it contains troublesome characters
Upvotes: 1
Reputation: 33534
I need to make the client able to upload a file from the local computer to the server
- Open a Solely Dedicated Connection
to the Server for File uploading.
- Use File Transfer Protocol
to ease your work, and moreover its quite easy and reliable to use the Apache's common lib
for File uploading and downloading....
See this link:
http://commons.apache.org/net/
Upvotes: 1
Reputation: 229361
You really only have two options:
The former seems simpler & cleaner to me, requiring less overhead and less complicated code.
Upvotes: 1