       },
       'body': multipartRequestBody})
 
-  update: (fileId, title, content, callback) ->
-    console.log('update file')
+  update: (fileId, title, content) ->
     multipartRequestBody = this.requestBody(title, content)
-    request = gapi.client.request({
+    return gapi.client.request({
       'path': '/upload/drive/v2/files/' + fileId,
       'method': 'PUT',
       'params': {'uploadType': 'multipart'},


    if this.get("file")
      this.update(title, content)
      Promise.resolve('update')
    else
      this.insert(title, content)
      Promise.resolve('insert')

  insert: (title, content) ->
    that = this


        Promise.resolve(response.result)

  update: (title, content) ->
    that = this
    fileId = that.get('file').id
    gapi.client.load('drive', 'v2')
      .then () -> that.gdrive.update(fileId, title, content)
      .then (response) ->
        console.log("update file")
        console.log(response.result)
        that.set("file", response.result)

        Promise.resolve(response.result)
})

GDriveView = Backbone.View.extend({
  el: '#gdrive'
  events:
