文件上传不适用于Sails.js

时间:2014-07-10 18:15:59

标签: javascript sails.js skipper

我尝试使用以下代码将图像上传到服务器。它适用于最大约70KB的小图像。

对于较大的图像,它将文件状态设置为cancelled,保存到服务器磁盘,但大小为零KB

var CustomerController = {

  uploadPhoto: function (request, response) {

    var customerId = request.param('id');

    // check for the existence of the customer

    Customer.findOne({
      id: customerId
    }).exec(function (err, customer) {

      if (err || !customer) {
        return response.notFound('Customer not found');
      }

      // get the file that was uploaded from the client
      // and save it to disk

      request.file('photo').upload(function onUploadComplete(err, files) {

        if (err || !files || files.length < 1)
          return response.serverError('Error uploading photo: ' + err);

        // do something with files here

      });


    });


  },

  _config: {}

};

module.exports = CustomerController;

我使用Sails 0.10.0-rc7。

有什么想法吗?

0 个答案:

没有答案