       base64Data +
       close_delim
 
-    request = gapi.client.request({
-      'path': '/upload/drive/v2/files',
-      'method': 'POST',
-      'params': {'uploadType': 'multipart'},
-      'headers': {
-        'Content-Type': 'multipart/mixed; boundary="' + boundary + '"'
-      },
-      'body': multipartRequestBody})
-    if (!callback)
-      callback = (file) ->
-        console.log(file)
-    request.execute(callback)
+    return multipartRequestBody
 
   utf8_to_b64: (str) ->
     window.btoa( unescape(encodeURIComponent( str ) ) )
 
+
 GDriveModel = Backbone.Model.extend({
   initialize: ()->
-    this.CLIENT_ID = '966231612988-cmob8calt2b646p4sddlb4410q2eekmq'
-    + '.apps.googleusercontent.com'
-    this.SCOPES = 'https://www.googleapis.com/auth/drive'
+    this.gdrive = new GDrive()
     this.authResult = this.authorize()
+    this.file = null
 
   authorize: ()->
     that = this
     return null unless gapi.auth
 
     gapi.auth.authorize({
-      'client_id': this.CLIENT_ID,
-      'scope': this.SCOPES,
+      'client_id': this.gdrive.CLIENT_ID,
+      'scope': this.gdrive.SCOPES,
       'immediate': true },
       (authResult)->
         # immediate: trueが失敗したときはflaseで再チャレンジ

        else
          console.log("immediate false")
          gapi.auth.authorize({
            'client_id': that.CLIENT_ID,
            'scope': that.SCOPES,
            'immediate': false },
            (authResult)->
              that.authResult = authResult
          )
    )
})
GDriveView = Backbone.View.extend({
  el: '#gdrive'
  events:
    'click [name=authorize-button]': 'gapi_authorize'
    'click [name=upload-button]': 'upload_text'
  initialize: ()->

  gapi_authorize: ()->
    this.model.authorize()
  upload_text: ()->
    GDrive.prototype.uploadFile()
})

gdriveModel = new GDriveModel()

  CLIENT_ID: '966231612988-cmob8calt2b646p4sddlb4410q2eekmq' +
  '.apps.googleusercontent.com'
  SCOPES: 'https://www.googleapis.com/auth/drive'
  BOUNDARY = '-------314159265358979323846'

  requestBody: (title, content)->
    delimiter = "\r\n--" + this.BOUNDARY + "\r\n"
    close_delim = "\r\n--" + this.BOUNDARY + "--"

    contentType = 'text/plain'
    metadata = {
      'title': title,
      'mimeType': contentType
    }

    base64Data = this.utf8_to_b64(content)
    multipartRequestBody =
      delimiter +
      'Content-Type: application/json\r\n\r\n' +
