Coffeescript 使用请求将文件上载到CouchDB的Grunt任务

Coffeescript 使用请求将文件上载到CouchDB的Grunt任务,coffeescript,gruntjs,couchdb,Coffeescript,Gruntjs,Couchdb,在我的Gruntfile.coffee中,我设置了一个任务: grunt.registerTask 'couch_upload', 'CouchDB upload', -> done = @async() assets = ['combined.min.js', 'screen.min.css'] ddoc = 'http://localhost:5984/mydb/_design/app' request = require 'request' fs = requi

在我的
Gruntfile.coffee
中,我设置了一个任务:

grunt.registerTask 'couch_upload', 'CouchDB upload', ->
  done = @async()

  assets = ['combined.min.js', 'screen.min.css']
  ddoc = 'http://localhost:5984/mydb/_design/app'
  request = require 'request'
  fs = require 'fs'
  grunt.log.writeln 'Uploading assets...'

  upload = (asset) ->
    # get the revision of the design document
    request.get {json: yes, url: ddoc}, (err, resp, body) ->
      rev = body._rev
      # stream the file and pipe it, so it has the correct Content-Type
      fs.createReadStream('build/' + asset).pipe request.put
        auth: user: 'myusername', password: 'mypass'
        headers: 'If-Match': rev
        url: [ddoc, asset].join '/'
      , -> grunt.log.write ' ' + asset

  upload asset for asset in assets

  done()
但我看不到上传的任何东西,无论是在格朗特的日志上,还是在科奇的日志上


你能告诉我我是否做错了吗?

听起来你需要向CouchDB Lucene打开一个功能请求:-如果可能的话,它看起来还没有启用该功能。

我感谢你的回答,但Lucene没有参与其中。CouchDB支持附件上传。这是某种异步问题;有些/所有这些情况都会发生:1)第二个文件报告409(文档冲突),2)fs piping覆盖所有其他标题(如auth和If Match)3)JSON.strigify将顺序与多部分/相关的文件混淆。我可以只使用一个文件,但不能使用多个文件。即使是在不同的任务中。我本想把这个贴在不同的问题上,忽略我。对不起D