In November-2014, we released the Resilio 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.
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.
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 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.
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.
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.
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.
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.
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.