javascript - 通过API调用使用react redux进行文件上传

标签 javascript reactjs express react-redux redux-form

我想上传一个带有 react-redux-universal-hot-example 的文件样板文件。

提交时,将调用以下函数(由 ApiClient 管理):

export function update(data) {
  return {
    types: [UPLOAD, UPLOAD_SUCCESS, UPLOAD_FAIL],
    promise: (client) => client.post('/project/update', {
      files: data
    })
  };
}

在服务器端,调用以下函数(由 Api 管理):

export default function update(req, params) {
  // get the file
}

文件信息位于哪里?

最佳答案

您需要一个 Express 中间件来处理多部分/表单数据,例如 Multer .

关于javascript - 通过API调用使用react redux进行文件上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42490255/

相关文章:

javascript - 为什么这个js代码有效?

javascript - Google 饼图在函数内使用 Jquery?

javascript - 在 Angular 2 App 中转换双向绑定(bind)属性中的日期

javascript - react : Confusing behavior with useEffect and/or useState hooks

node.js - 连接到 AWS Postgres SequelizeConnectionError : password authentication failed

javascript - 从 JavaScript 中的对象返回两个单独的数组

javascript - ReactJS 搜索页面设置/获取查询字符串

javascript - 如何从 POST 读取数据、使用条件测试数据并发回响应

node.js - 蒙戈/ express : How to return all documents in collection if no query params are passed?

reactjs - 用参数 react 路由器?