【问题标题】:React post image file upload issue - Production only反应发布图像文件上传问题 - 仅限生产
【发布时间】:2018-11-08 20:51:18
【问题描述】:

我正在尝试附加图像文件。不知何故,如果在那里附加文件,我的客户端没有发送任何内容。

它在 React(website) 和 React-Native Web View(rendering) 上。

游戏的坏处是,我无法跟踪客户端日志,导致移动浏览器问题。

1)

const formData = new FormData();
formData.append('report[description]', text);
formData.append('token', localStorage.getItem('tempToken'));
formData.append('report[image]', new Blob([this.state.file], { type: 'image/png' }));
axios.post('/accept_report', formData)

2)

const config = {
   headers: {
     'content-type': 'multipart/form-data'
   }
}
formData.append('report[image]', this.state.file);
axios.post("/accept_report", formData, config)

【问题讨论】:

  • 那么你遇到了什么错误?
  • @IsaacVidrine 实际上什么都没有,因为从浏览器我可以看到日志并正常工作。但是在移动设备上我看不到日志,甚至没有请求服务器。

标签: javascript ruby-on-rails reactjs react-native axios


【解决方案1】:

已解决:

因为,它仅在附加文件时发生。我的产品nginx 限制了大文件。我只能上传大约 500kb 没有结束。

已更改 nginx 客户端正文大小。

http{
   #...
   client_max_body_size 10M; #or 100M it depends on yr preference.
   #...
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多