     # .then (result) =>
   upload: (cell, module)->
     cell.changeState 'upload'
-
+    @loading.show();
     @login 'cube', 'cube', 'cube'
     .then (result) =>
       throw new Error('login fail') unless result.result is 'true'
       console.log "upload"
-      zip = new AdmZip()
-      # zip.addLocalFolder path.join(atom.project.path, 'encrypt', module.package.identifier)
-      zip.addLocalFolder module.path
-      @uploadAttach zip.toBuffer()
+      zip(module.path, module.path).then (zipPath) =>
+        @uploadAttach zipPath + '.zip'
     .then (result) =>
       console.log "validate"
       throw new Error('upload fail') unless result.result is 'success'

  validateAttach: (id) ->
    request_get "#{C_Server}/bsl-web/mam/attachment/readfile/#{id}"

  uploadAttach: (buf) ->

    Q.Promise (resolve, reject, notify) ->
      r = request.post "#{C_Server}/bsl-web/mam/attachment/upload", (err, res, body)=>
          if err then reject(err) else resolve JSON.parse(body)

      form = r.form()
      form.append "file", buf,
        filename: 'upload.zip'
        contentType: 'application/zip'


{View} = require "atom"
_ = require "underscore"
zip = require '../../utils/zip'
path = require 'path'
fs = require 'fs'
request = require 'request'
