javascript - 反应发布图像文件上传问题 - 仅限生产
问题描述
我正在尝试附加图像文件。如果在此处附加文件,我的客户端以某种方式没有发送任何内容。
它在 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)
解决方案
解决了:
因为,它仅在附加文件时发生。我的作品nginx
限制了大文件。我只能上传大约 500kb 没有结束。
改变了nginx
客户的体型。
http{
#...
client_max_body_size 10M; #or 100M it depends on yr preference.
#...
}
推荐阅读
- c# - 将功能绑定到 QR 码或用作提交按钮 blazor
- amazon-web-services - 手动触发 50 多个 AWS 代码管道
- c# - 调用存储过程时如何测试 C# EF 核心 DbContext.Database.ExecuteSqlRaw()?
- android - 使用 Android Studio UI 组件创建通知
- oracle - 关于 AWS 性能问题的 ORDS
- java - 当tomcat工作线程重用时会发生什么?
- angularjs - 使用 ASP.NET Web API、存储过程和 AngularJs 创建登录表单
- javascript - 如何从数组中对所有匹配的对象进行分组,匹配将在多个键上
- r - tidyr中的gather(),两个不同的代码,一个是正确的,另一个是错误的
- android - Telegram android项目中的断点未命中本机c/c++