Sync Hacks: BitBox Generates Unique URL for Your Sync Files, Built on Sync API

Sync Hacks is a column dedicated to exploring new applications for Sync, as built by users like you. BitTorrent Sync is a free, unlimited, secure file-syncing app. (And now, it’s 2X faster.) If you’ve got an epic Sync idea, use-case or how-to, shoot us an email at sync[at]bittorrent.com.

In November, we released the BitTorrent Sync API. In this week’s Sync Hacks, we are excited to highlight – for the first time – one of the applications developed on top of it: BitBox. Built by Colin McFadden of divergent media, BitBox is a tool that makes sharing big files with customers even easier, by allowing you to create unique links for all of your Sync files.

synchacks4

From Colin:

The Problem

I’m a developer at divergent media. We make Mac apps for working with video. Part of our development process involves testing with large amounts of “real world” video files. We’ve got hundreds of gigabytes of test media that we need to routinely work with. Normally, that’d just live on shared storage in an office, but our development team is split between San Francisco and Minnesota. For performance reasons, this means we need to maintain local copies of this media.

We’ve tried a number of solutions for keeping a large set of media in sync across our locations. We bought fancy syncing NAS devices. We looked at expensive cloud solutions. None of them met our needs for “set it and forget it” reliability with reasonable costs for big data sets. One day, our lead developer saw a billboard for BitTorrent Sync. We were at the point of peak frustration with our most recent hardware purchase, so we gave it a try.

BitTorrent Sync

After a few days of experimentation, it was clear that BitTorrent Sync was the solution we needed. There was just one element missing – we often need to share large files with our customers. While BitTorrent Sync is easy, asking a customer to download a special program just to get a file isn’t always ideal.

We toyed with ideas for putting a web sharing frontend on BitTorrent Sync, but they were all destined to be a bit “hacky.” Then, the BitTorrent Sync API was revealed, and a simple web frontend became far more realistic. After a morning of work, BitBox was born.

BitBox

BitBox is a web application which interfaces with the BitTorrent Sync client using the API. It allows us to create a unique URL for any file on unique URL BitTorrent Sync and then send that to a customer. By using the “selective sync” feature of the API, only the files we’re actively sharing need to live on the server.

Because files get a special extension while they’re still syncing, we can give the customer feedback on their download, and start sending as soon as the file is synced.

Installation

What you’ll need

BitBox, a CodeIgniter web application.

BitTorrent Sync API key (in order to use BitBox).

• BitBox requires either the pecl_http library for php or mod-xsendfile for Apache. Both can easily be installed via tools like apt-get. By default, BitBox uses mod-xsendfile – see application/controllers/download.php to switch to pecl_http. IF you’re using mod-xsendfile, be sure your BitBox virtual host has mod-xsendfile enabled.

Steps

1. Start by configuring Sync on your computer. You’ll need to enable the API with your API key, and confirm that the Sync client is accessible via the web (port 8888).

2. Create a local MySQL user and database for this application, and populate the information in application/config/database.php. You should also fill in the top section of application/config/config.php (up through the address for your host).

3. Download the current release of CodeIgniter and place the system folder and index.php in the BitBox root.

4. Edit index.php and add the line include_once ‘./vendor/autoload.php’; to the top of the file.

5. In the BitBox root, run curl -sS https://getcomposer.org/installer | php to install Composer. Then run php composer.phar install to get the php dependencies.

6. Run php -r “$(curl -fsSL http://getsparks.org/go-sparks)” to install CodeIgniter Sparks, then run php tools/spark install -v1.3.0 curl to get the Sparks dependencies.

You’ve now got all the necessary components. You may need to edit the .htaccess file to match your server (see the normal CodeIgniter instructions for details).

7. Next, run php doctrineHelper.php orm:schema-tool:create to create the necessary MySQL tables.

You should now be able to access BitBox via the web, at “youraddress/admin” – the username and password are defined in the config.php file.

synchacks1

Make sure the “application/models/Proxies” folder is writeable by your web server.

At this point, try adding a BitTorrent Sync folder – paste in the shared secret, and set the absolute path that you’d like to store the files on your server. Be sure you’ve got permission to write to that folder. You should be able to browse the files in that folder, and mark them for sharing.

synchacks2

When a file is shared, BitBox asks BitTorrent Sync to begin syncing. It can take a few seconds for the download to start. You can access the sharing URL while the file is still syncing – the download will automatically start when the sync is complete.

synchacks3

Help Build BitBox

We decided to open source BitBox, because we think it’s a useful addition to a great technology. We’d love to work with other developers to add features – for example, a drop folder for users to upload into (given a unique ticket) would be a great addition. Get in touch with us if you’d like to contribute, and thanks to BitTorrent for creating such a powerful platform.

Colin McFadden (@cmcfadden) is a software developer at divergent media in San Francisco. He helps create media applications for Mac users.

Lou
Written by: Lou

Lou is a product marketing manager at BitTorrent, Inc., where he works on BitTorrent Sync, a free app that allows you to sync and share large files with anybody via secure, distributed technology.

 Related Posts:
  • http://www.fsession.com joie fsession

    T’s in point of fact a nice and useful piece of information. I’m glad that you simply shared this useful information with us. Please stay us informed like this. Thanks for sharing.

  • Curious

    Is it possible to force an upload user to encrypt their files? This would be useful for file storage. I don’t want to be able to access their files.

  • Ben K

    This definitely looks like something I could use at work. However, I’ve followed all the steps on a brand new Debian VM and I’m not able to access the admin page. I can open up the normal Bittorrent Sync webgui just fine, but I get “requested URL not found on the server” when I try the admin directory.