0

我正在尝试上传文件,我正在使用“Angular File Upload”。尝试连接并将文件发送到 mongodb,但它在 firebug 上出现此错误

净::ERR_INSECURE_RESPONSE

在 mongodb.log 日志文件中,它显示连接已完成:

2014-11-09T11:57:05.512+0400 I NETWORK [initandlisten] 接受来自 xxx.xxx:53749 #2 的连接(现在打开 1 个连接)

2014-11-09T11:57:05.524+0400 I NETWORK [conn2] 结束连接 xxx.xxx:53749(现在打开 0 个连接)

我还创建并使用了 ssl 证书。

我的 Angular Js 代码是:

$scope.onFileSelect = function($files) {        

    //$files: an array of files selected, each file has name, size, and type.    
    for (var i = 0; i < $files.length; i++) {    
      var $file = $files[i];    
      $upload.upload({          

        url: "https://localhost:27017/mydb",    
        file: $file,    
        progress: function(e){  console.log("Progress: ");}

      }).then(function(data, status, headers, config) {    
        // file is uploaded successfully    
        console.log("File Uploaded : "+ data);    
      });    
    }


  };
4

1 回答 1

0

You'll need an interim step there. Going directly from Angular to Mongo will not work out. If you want a generic REST interface to Mongo with which you can utilize Angular's bundled $http services, take a look at the list of REST services on Mongo's site.

Mongo REST Services

http://www.mongodb.org/display/DOCS/Http+Interface#HttpInterface-RESTInterfaces

Angular $http Service:

http://docs.angularjs.org/api/ng.$http

There's a lot of different options here, but this is likely the easiest way to get up and going.

var mongoose = require('mongoose');
var db = mongoose.createConnection('mongodb://localhost:3000/database');
var orderSchema = new mongoose.Schema({
    routeFrom : String,
    routeTo : String,
    leaving: String
});
var Order = db.model('Order', orderSchema);
module.exports = Order;
于 2014-11-09T08:19:28.183 回答