It works across multiple devices (your phone and your tablet). If you delete a file on one side, it will be deleted on the other side. New files in your cloud account are automatically downloaded onto your device. It is an ideal tool for photo sync, document and file backup, automatic file transfer, automatic file sharing between devices. It lets you automatically synchronize files and folders with Dropbox cloud storage and with your other devices. GetFileCheckSum(MessageDigest,file) hashes the file with the specified MessageDigest hash algorithm.This app is an automatic file sync and backup tool. Also calls getFileCheckSum function to hash the file. GetFilesFromFolder returns the files in the specified directory as FileTuples. These are the commands that can be executed with the command coming from the follower. Master listens the console and the data retrieved from the socket. UploadFile, creates a new file with the file name in the Dropbox account app folder. GetAlreadyUploadedFiles returns the files in the linked Dropbox account app folder.ĭeleteFile, deletes the file in the path. We have functions named: getAlreadyUploadedFiles(), deleteFile(path),uploadFile(fileName,path). We linked our account with the core api with the access token we get after created the app. For this purpose, we created a separate class named DropboxFileManagement.java. Than we need to connect to our Dropbox account with the Dropbox core Api. We created an application in the Dropbox. To sync with the master with the Dropbox, we used Dropbox Core Api v2. We used this object while determining if we should update,delete or add the file to master and the client. FileTuples(name,hash,updateDate) which has other attributes named, consistency and size. We have a class to store the files called FileTuples.java. However, with more debugging we could have achieved what is the problem and could be implemented. So we decided to cancel these and decided to move on with only one socket. We had some problems while determining the file size because file.getLength() method which should return us the file size, returned always 0 and the socket connections could not run as the expected way. However, we had some issues after we implement these methods. When the data sent again, if it passes the validity check, other threads can continue executing the combining part. If the data is corrupted in the socket, we catch this error in the catch area of the combining data and tell other threads to wait for the data to be sent again. So we will make sure the data is not corrupted or combined falsely. For this purpose we used synchronized(buffer) loop to retrieve the data in a synchronized way to be sure we created the file with the correct bytes as the file is sent. To retrieve the file, we should have synchronized the data coming from the sockets. After that we decided how much size the buffers that is used to send and retrieve the data to be.Īfter the ports are opened and the buffer size is determined we started to send the data through the socket. After the port size is determined we opened the data sockets as new threads and wait for the connection to be established. To divide the file in chunks we get the size of the file and decided on the port number to be opened. We send the commands and the data between the master and the follower as bytes. To establish the data flow between the master and the follower, we created the socket connections between them and used DataInputStream and DataOutputStream java classes to fetch,send the commands and two retrieve and send the data between the followers and the masters. We named the DropSync folder in the follower as DropSync1 and the DropSync folder in the master as DropSync. When the follower added/deleted/updated the files in the master, the master can execute these required actions to sync itself with the dropbox. The master can execute a dropbox sync method to sync its files with the Dropbox folder. The follower can execute a sync check on the dropbox folder to see the deleted/added/updated files in the master and sync his/her files with the dropbox by getting the files from the master. After the client socket accepted and the connection between the master and follower is established the master starts waiting for client commands. We can think them as two separate projects working as the follower and the master respectively.įirst of all, we created our ServerSocket which can handle multiple clients by running the client socket connections on separate threads. There are two packages in our project which is “Client” and “MultiThreadServer”. The project aims to sync the folder of the user with the Dropbox folder that is capable of handling multiple clients. In this project, we implemented a Dropbox Sync that works on the application layer project.