This project provides a client app to upload any folder or file to another local folder of the same PC or to another lan-PC wherever the respective server is running.
This project is done as an assignment for the "Networking sessional" (course CSE-322) of the CSE department of BUET.
Whatever, I'll also use this project to transfer file between my laptop & PC lanned together via a wifi-router :D .
- Each of the server & client GUIs are in separate classes, whose instants are used inside the
Server.java
&Client.java
. - The server continues to listen for an incoming request to the selected port inside an infinite loop running inside a thread.
- If a single file is selected to upload, then:
- open a socket to the specified server address & port number;
- get
ObjectOutputStream
from the opened socket; - send the file parent, file name & file size;
- finally send the file by 8192 bytes each time;
- receive the requested objects sequentially at the server-side.
- If a directory is selected to upload, then:
- open a socket to the specified server address & port number;
- get
ObjectOutputStream
from the opened socket; - send a
KEY_DIRECTORY
to tell the server-side that a directory is to be downloaded; - send the parent of the directory as the "client head", which will help to identify the sub-directoried save-location of the nested-folders & files at the server-side;
- list all files inside the directory as well as inside its sub-directories iteratively;
- send each file as the single-file-upload-process described above.
- send
KEY_DIR_STOPPER
to stop accepting files at the server-end when all files have been transferred.
The project is developed in Eclipse IDE.
Eclipse:
- Import the project in eclipse (
File>Import..
). If the client & server PCs are different, then import the project in both PCs' Eclipse IDE. - In the server(target) PC, Run the
Server.java
class (insidecom.touhiDroid.JFileUploader.Server
package) byright click > "Run As" > "Java Application"
, or selecting it & then pressingCtrl+F11
- Provide the target save-location & click "Set Path". Similarly, set a port (in between 1025 & 65535).
- In a similar fashion, run the
Client.java
class (insidecom.touhiDroid.JFileUploader.Client
package) in the client PC. - If the client & server PC is the same, then write
localhost
in the "Server URL" field, otherwise write the IP address of the server PC (as192.168.0.100
) - Specify the
Server Port
as the same as specified in the server app. - Select a file/folder in the file chooser & click "Upload" button.
Command Prompt:
- Go to the
JFileUploader>src>com>touhiDroid>JFileUploader>Server
in the server PC & runServer.java
class. - Specify target save-location & server-port clicking on the set buttons.
- Go to the
JFileUploader>src>com>touhiDroid>JFileUploader>Client
in the client PC & runClient.java
class. - Specify server IP / destination folder & port no. same as the server-port.
- Choose the file to upload & click the "Upload" button in the client app.
- Progress bars doesn't show proper progresses, though the console helps to understand the current progress.
- Sometimes the uploaded files uploads successfully but it shows size 0KB, though it gets fixed when it is opened by any text-editor or some app. like this.
- While uploading a big-size folder (esp. containing nested folders) , some files gets corrupted (though transferred with full size) & can't be opened.
- Files bigger than 240MB causes Java heap-size overflow exception.
- Server-side file format specification: a new filed & check the first file/directory name-format.
- Server-side file type(extension) specification: check the file extension from the file name before proceding with the saving.
- Multiple submission confirmation from client: Client remembers the previous submission & alerts in case of matching file/folder name.