离子文件传输太大了?

时间:2018-06-10 17:13:35

标签: node.js express ionic-framework ionic3 multer

我有一个离子3应用程序,我正在使用离子原生相机和文件传输插件拍照并发送到我的Node.js / Express API来存储图像文件。

在我的服务器上,我正在使用'multer'。

似乎一切正常,但当我尝试上传图片时,我收到以下错误:

2018-06-10 10:05:25.052951-0700 SynctupV3[3058:1625890] CDVWKWebViewEngine: handleStopScroll
2018-06-10 10:05:25.601142-0700 SynctupV3[3058:1626144] WriteStreamError domain: 0 error: 0
2018-06-10 10:05:25.605004-0700 SynctupV3[3058:1626399] File Transfer Finished with response code 413
2018-06-10 10:05:25.755113-0700 SynctupV3[3058:1626399] FileTransferError {
    body = "<html>
\n<head><title>413 Request Entity Too Large</title></head>
\n<body bgcolor=\"white\">
\n<center><h1>413 Request Entity Too Large</h1></center>
\n<hr><center>nginx/1.10.3 (Ubuntu)</center>
\n</body>
\n</html>

我的multer实现非常简单:

var express = require('express');
var router = express.Router();
var multer = require('multer');
var upload = multer({dest:'fileuploads/'});
var constants = require('./helpers/constants');

router.route
  .post('/', upload.any(),function(req, res, next){

  res.send(req.files);

})

module.exports = router;

这就是我在UI方面的文件传输:

  uploadImage(){
    let loader = this.loader.create({
      content: 'uploading...'
    });
    loader.present();

    const fileTransfer : FileTransferObject = this.transfer.create();

    var random = Math.floor(Math.random() * 100);

    let options: FileUploadOptions = {
      fileKey: 'photo',
      fileName: 'myimage_' + random + '.jpg',
      chunkedMode: false,
      httpMethod: 'post',
      mimeType: 'image/jpeg',
      headers:{
        Connection: "close"
      }
    }

    fileTransfer.upload(this.myPhoto, this.globals.API_ENDPOINT + 'uploads', options)
      .then((data)=> {
        alert('Success');
        loader.dismiss();
      }, (err)=>{
        alert(err);
        loader.dismiss();
      })

  }

任何人都可以提出我的看法吗?

0 个答案:

没有答案