Sign in to follow this  
osafi

Btsync-Java: Java Wrapper For Api

Recommended Posts

A few months ago I created a wrapper library for the Sync API as part of a much larger project but I never got around to publishing it. It is slightly more than just a wrapper as it also contains binaries and will take care of starting and stopping Sync so it makes working with Sync within Java applications much easier.

Now that I had a bit of time I finally published the project to the Maven Central Repository. It is still in a very early stage and needs a lot of testing so please let me know of any problems you encounter.

 

See the project at:

Bitbucket - https://bitbucket.org/osafi/btsync-java

GitHub - https://github.com/commandersafi/BTSync-Java

 

 

Description of project copied from git repository:

 

Purpose

BTSync-Java is a library for the starting and interacting with BitTorrent Sync Beta. To use this library you must have received an API Key from BitTorrent Sync which can be done here.
Bundled with this library is the 1.3.105 version of the BitTorrent Sync Beta binary (32bit) for Windows and Linux. Mac support will be added in one of the next updates.

 

Background

This library was created as part of my senior design project, a Universal User Experience system sponsored by HP. My team and I decided to use BitTorrent Sync as our synchronizing agent and needed to be able to start, stop, and interact with BT Sync completely in the background without it being previously installed or require user interaction.

 

Maven Dependency

Add the following dependency to your pom.xml to use BTSync-Java

<dependency>    <groupId>ms.safi.btsync</groupId>    <artifactId>btsync-java</artifactId>    <version>0.1</version></dependency>

NOTE: There is another artifact in Maven Central under the artifact BTSync-Java which SHOULD NOT be used as it was mistakenly added and will not receive future updates.

 

 

 

Snippit showing usage:

public class TestBTSync {    public static String API_KEY = "MYAPIKEY";    public static void main(String[] args) {        try(BTSyncApp app = new BTSyncApp(API_KEY)) {            // 1. Start BitTorrent Sync and get an instance of BTSyncClient to interact with it            BTSyncClient client = app.startBtSync();            // 2. Try to add a folder to BitTorrent Sync - print out the error if unsuccessful            if(!client.addFolder("C:\\Users\\OSafi\\Desktop\\Stuff")) {                System.out.println("Could not add folder");                System.out.println(client.getLastError());            }            // 3. Use the API to shutdown your BitTorrent Sync instance            client.shutdown();        } catch (Exception e) {            e.printStackTrace();        }    }}
Edited by osafi

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this