Custom Server Setup

 

Set up one-click data exchange with your computer.

In ND1, you can upload and download your user folders via each folder’s Sharing page for your safe-keeping. This uses a naivedesign.com server. You can also set up a custom server to allow easy data exchange and editing with your own server.
A custom server is currently the only method to get data into ND1.


If you want to import data into ND1, or edit ND1 user data, you need to set up a custom server.

It’s easy to have your own server.

You need one thing:

  1. -access to a working (HTTP) webserver under your control, with PHP enabled


If you have OS X, getting a working server is as simple as turning on Web Sharing in System Preferences | Sharing.


Once you have that, create a file somewhere under your server’s DOCROOT (~/Sites on Mac) and paste the following code into it:


<?php

$id = $_GET['clientID'];

$type = $_GET['type'];

$category = $_GET['category'];


if ($id == '' || $type == '' || $category == '') {

    die('Required upload params missing');

}


$data = file_get_contents("php://input");

$uploaddir = 'uploads/';

$uploadfile = $uploaddir . $id . '_' . $type . '_' . $category . '.txt';


$fd = fopen($uploadfile, "w");

if ($fd) {

    fwrite($fd, $data);

    fclose($fd);

}


echo 'ok';

?>


We recommend a filename “upload.php”. It needs to have a .php extension.

Finally, create an “uploads” folder in the same folder.

You’re done on the server side.


The code above will write incoming ND1 data into a file in your uploads folder, where the filename will indicate the type of data, the folder name, and your ND1 user id.


Now, in ND1, go to the folder you want to share with your custom server, and enter a valid URL, that points to your upload.php page, into the text field. The URL depends on your local network configuration (test it out with Mobile Safari), but it’s probably going to look like this:

http://192.168.0.x/~user/upload.php


Flick the Custom Sharing URL switch to ON and the next time you tap Upload the data should go right into your uploads folder. You can then edit the data and get it back into ND1 by tapping Download.

It’s one-tap either direction, with nothing else to do!


Important: Edit the data with a proper JSON editor! (There are many free ones.)
If you use a text editor, make sure you import text as UTF-8. You may have to explicitly tell the program to use UTF-8. (TextEdit on Mac, for example, will not correctly import the data unless you switch “Plain Text Encoding” to “Unicode (UTF-8)” in the Open... dialog.)


Did we mention you should use a JSON editor? Only a JSON editor will guarantee that your data remains correct JSON. It’s all too easy to break it with a text editor, esp. if you want to write a larger program.


If you want to use that same custom server per default, go to the Settings app, find ND1, and enter the same URL in the Custom Sharing URL field, under Advanced. This will serve to pre-populate the text field in the Sharing dialog.


You can always switch back to using our server by flicking the Custom Sharing URL switch back to OFF. Its setting is remembered by each folder individually.


Final note: Public sharing only works with our server, of course. If you work on cool projects that could be shared with other ND1 users, please consider doing so. Thank you.
 

(c) 2010 Naive Design. All rights reserved.

pdf (6/02/10)http://naivedesign.com/docs/ND1_CustomServerSetup.pdf