Last active
December 14, 2015 02:29
-
-
Save hc2p/5013922 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upload: function(file) { | |
var def = new $.Deferred(); | |
var that = this; | |
var xhr = this.client.writeFile(file.name, file, {noOverwrite: true}, function(error, metadata) { | |
if (error) { | |
def.reject(error); | |
return; | |
} | |
def.resolve(metadata); | |
}, this.onUploadProgress); | |
return def.promise(); | |
}, | |
getSharedUrl: function(metadata) { | |
var def = new $.Deferred(); | |
var that = this; | |
this.client.makeUrl(metadata.path, function(error, metadata) { | |
if (error) { | |
def.reject(error); | |
return; | |
} | |
def.resolve(metadata); | |
}, this.onSharedUrlProgress); | |
return def.promise(); | |
} | |
$.when(this.upload(file)). | |
pipe(this.getSharedUrl). | |
done(...). | |
fail(...); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment