Skip to content

Instantly share code, notes, and snippets.

@superlou
Created April 8, 2015 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save superlou/05e1159c5f236c46d73d to your computer and use it in GitHub Desktop.
Save superlou/05e1159c5f236c46d73d to your computer and use it in GitHub Desktop.
Dropbox Store
var DropboxOnlineAdapter = DS.Adapter.extend({
find: function(store, type, id, snapshot) {
var dropbox = this.container.lookup('service:dropbox');
var path = this.filename(type, id);
return dropbox.files(path).then((result) => {
var data = {
id: id,
text: result
};
var model = store.push(type, data);
return model;
});
},
findAll: function(store, type, sinceToken) {
var dropbox = this.container.lookup('service:dropbox');
var dropboxFiles = dropbox.metadata('').then((result) => {
return result.contents.map((item) => {
return item.path.match(/\/([\w]*)\.fountain/)[1];
});
}).then((ids) => {
return ids.map((id) => {
return this.find(store, type, id);
});
});
console.log(dropboxFiles);
return dropboxFiles;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment