-- Author: Aditya R.Singh
-- Date: 16-02-2015
-- Company: SE CMPN, Shri L.R.Tiwari College of Engineering, Mira Road.
This is a simple image transfer app intended to be embedded with other project.
This is based on a client server model. What the app does is, all images clicked by a camera is put
in the outbox
directory on the client side. The image is then transferred to the server over Sockets
and is placed in the inbox
directory on the server.
- outbox/
- bin/com/adi/client/ProjectClient.class
- bin/com/adi/photo/Photo.class
- bin/com/adi/transfer/HostDetails.class
- bin/com/adi/FileTransferListener.class
- bin/com/adi/FileTransferListener$1.class
- inbox/
- com/adi/photo/Photo.class
- com/adi/server/ProjectServer.class
- com/adi/server/ProjectServer$1.class
-
Turn the server on.
java -cp bin com.adi.server.ProjectServer
Make sure to turn on the database server too and configure your database details in the properties/database.properties file.
-
On the client side, turn the DemoTransfer on.
java -cp bin DemoTransfer
-
And we are done.
-
Create an object of
com.adi.transfer.HostDetails
with Server IP address and Port number to connect the socket to.
Example:com.adi.transfer.HostDetails host = new com.adi.transfer.HostDetails("64.78.223.98", 80);
This will save the details of the server to be connected to.
-
Create an object of
com.adi.client.ProjectClient
with the object ofcom.adi.transfer.HostDetails
as a parameter.
Example:com.adi.client.ProjectClient client = new com.adi.client.ProjectClient(host);
This will connect the Client socket to IP address
64.78.223.98
on port80
. Seestep 1
for clarification. -
Call the
static
methodstart()
from thecom.adi.FileTransfer
class withcom.adi.client.ProjectClient
object and the absolute or relative path of the directory where your camera will store images as parameters.
Example:com.adi.FileTransferListener.start(client, "/Users/aditya/Desktop/Workspace/Java/FileTransfer/outbox/"); // Make sure the end the path of the directory with a '/'(forward slash).
This will start listening to the directory specified ("outbox" in this case) and will transfer any image that comes in the directory to the server specified in the
com.adi.transfer.HostDetails
object. -
See the
DemoTransfer.java
file for a demo on using the API. Where we have usedargs
as command line arguments.
These are the same args passed as mentioned inrunning the app
section. -
Good Luck!