File synchronisation

One of the least exciting but nonetheless necessary tasks involved with writing a content creation app for iOS is implementing a way to get data in and out of the app. While adding iTunes file sharing support is trivially easy, it’s pretty much expected that your app will also support online file storage services like Dropbox and WebDAV, which involves a lot more work. Most productivity apps on the iPad support this, so I had a look at number of them to see how they do it.

I found three main approaches:

  • Store all the documents locally, and provide import and export options for transferring individual documents between the iPad and the server. I don’t like this approach, because it means that if you’re regularly going back and forth between your computer and your iPad, you have to manually do the import/export each time, which is a pain.
  • Use iCloud. This is fine if you only ever want to access documents from the same app you created them in, the app is available for both your iPad/iPhone and your Mac, and the app supports iCloud on both platforms. But there’s no generic way of getting at your files from a PC or Mac, which I think makes it pretty useless. iWork documents are an exception, but even then you can only access them through a web interface, which doesn’t provide automatic synchronisation.
  • Allow access to files directly from the server, downloading them as necessary, and uploading them when they are saved.

I decided to go with this third approach, since it allows you to keep all your documents in one place and access them from anywhere – without the hassle of manually copying them back and forth all the time. But I noticed a couple of problems with the way in which the apps I looked at achieved this:

  • After closing a document, no local copy is kept on the iPad. It has to be re-downloaded each time you open it, even if it hasn’t changed on the server. Worse, you can’t access it offline – if you want to make some edits to your document on the train to work, you’re out of luck.
  • When saving a file, you are forced to wait for the upload to complete before you can carry on with your work.

In UX Write, I’ve implemented a file syncing mechanism similar to that of the PC and Mac Dropbox client. It works as follows:

  • UX Write keeps a local copy of any file you’ve previously opened. At regular intervals, or when you press “refresh”, it checks to see if these files have changed on the server and downloads any updated versions – in the background. You can also tell it to maintain a complete local copy of specific folders from your account.
  • If you try to open a file and there’s already a local copy of the latest version, it will open immediately.
  • When you save a file, it is written to local storage immediately, and uploaded in the background, while you continue with your work. If you’re not connected to the Internet at the time, it will upload the file later on, as soon as it gets a chance.
  • If the file has been modified independently on both the server and your iPad, you’ll be notified and given a chance to save your copy under a different name so you can later reconcile the differences.

The screenshot above shows what the file management interface looks like. Files that have a copy stored locally are shown in black, and files that exist on the server but not on the iPad are shown in grey. The icon to the right of each file shows its synchronisation status; the green ‘+’ over the iPad in some of these icons indicates that the file has been modified locally and is scheduled to be uploaded as soon as any other transfers have completed.

I’ve implemented these features in a generic manner which is not specific to any particular storage service, so it’s fairly easy for me to add support for new services. The first release of UX Write will support Dropbox and WebDAV, with other services being included in the future.

4 thoughts on “File synchronisation

  1. I’m foxed.
    Managed to go thorugh the Nazi hoops on the MAS site and upgraded to the Pro app. I can download a TXT document but I can’t write anything on the age that appears. Every other app I have works fine (Textilus, iAWriter, Noteabilility and so on).
    Should my document be in HTML format? Or is plain text ok?

    • Editing of text documents isn’t supported. Arguably there should be an option in there to convert to HTML/docx (its one of the things on my very long TODO list, and I’m not sure when or if it will get done). Basically the idea of the app is rich text editing – most of its features are irrelevant for plain text (no formatting, no styles, no outline etc) so I recommend using a dedicated text editor like Textastic if you’re working with plain text.

      One workaround however is that you can bring up the plain text file for viewing, and then copy & paste the contents into a new HTML or docx file. This is basically equivalent to the conversion option I mentioned above, but with one extra step.

      BTW when you do paste in plain text, it’s interpreted as Markdown, so any headings/lists etc. will be recognised as such if they’re written in the Markdown syntax.

  2. I’ve been looking for a program such as this for a long time….this is the only one where the developers have considered the practicalities of accessing and syncing when a user is in and out of wifi range, as many are a lot of the time. well done. I will be purchasing this very soon.
    CW

  3. Clever implementation. I vote for a Stronspace support, which is my favorite storage service (www.strongspace.com)

Comments are closed.