Last active

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

MakeDrive Client API Example

View index.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
// MakeDrive API - https://github.com/mozilla/makedrive
var MakeDrive = require('./path/to/makedrive.js');
 
// fs API - https://github.com/js-platform/filer#filer
var fs = MakeDrive.fs();
 
// Use fs right away, with or without network
fs.mkdir('/project', function(err) {
if(err) throw err;
 
fs.writeFile('/project/index.html', '<p>Hello World!</p>', function(err) {
if(err) throw err;
// /project/index.html is now written to disk
});
});
 
// When you want to sync, get the fs' sync object
var sync = fs.sync;
 
// Listen for events you care about
sync.on('error', function(err) {
// There was an error during syncing
});
 
sync.on('connected', function() {
// Connected to sync server
});
 
sync.on('disconnected', function() {
// Disconnected from sync server
});
 
sync.on('syncing', function() {
// Syncing with server
});
 
sync.on('completed', function() {
// Completed syncing with server
});
 
// Connect to the server
sync.connect('ws://server-url.com');
 
// [Optional, if in manual mode] Request an upstream sync with the server
sync.request();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.