     )
 
   upload: (title, content) ->
+    if this.file == null
+      this.insert(title, content)
+    else
+      this.update(title, content)
+
+  insert: (title, content) ->
     that = this
-    console.log('upload file')
-
-    console.log(content)
     gapi.client.load('drive', 'v2', ->
       that.gdrive.insert(title, content, (file)->
-        console.log(file)
+        that.file = file
+        )
+    )
+
+  update: (title, content) ->
+    that = this
+    gapi.client.load('drive', 'v2', ->
+      that.gdrive.update(that.file.id, title, content, (file)->
         that.file = file
         )
     )

    return multipartRequestBody

  insert: (title, content, callback) ->
    console.log('insert file')
    multipartRequestBody = this.requestBody(title, content)
    request = gapi.client.request({
      'path': '/upload/drive/v2/files',

        # immediate: trueが失敗したときはflaseで再チャレンジ
        # 今度はダイアログが開く
        if (authResult && !authResult.error)
          that.authResult = authResult
        else
          gapi.auth.authorize({
            'client_id': this.gdrive.CLIENT_ID,
            'scope': this.gdrive.SCOPES,
