Redux表单的文件类型是什么';上传图像时的文件输入?

Redux表单的文件类型是什么';上传图像时的文件输入?,redux,redux-form,Redux,Redux Form,我正在尝试使用允许用户上传图像。我可以用表单中的其他字段设置它。传递给my actions的jpg文件如下所示: { userImages: { value: [ { lastModified: 1467575553000, lastModifiedDate: Sun Jul 03 2016 15:52:33 GMT-0400 (EDT), name: "hero_bg.jpg", size: 96826,

我正在尝试使用允许用户上传图像。我可以用表单中的其他字段设置它。传递给my actions的jpg文件如下所示:

{
  userImages: {
    value: [
      {
        lastModified: 1467575553000,
        lastModifiedDate: Sun Jul 03 2016 15:52:33 GMT-0400 (EDT),
        name: "hero_bg.jpg",
        size: 96826,
        type : "image/jpeg",
        webkitRelativePath: ""
      }
    ]
  }
}
我正在使用并上传图像。然而,当我将userImages.value[0]作为我的文件传递时,它向我返回了一个400错误请求错误,这使我相信这是传递的文件信息的问题

在Cloudinary文档中,它们接受以下文件类型:

可以是实际数据(字节数组缓冲区)、数据URI(Base64 已编码),现有文件的远程FTP、HTTP或HTTPS URL,或 S3URL(白名单存储桶的)

所以,不要认为传下来的图像道具适合任何一个

以下是我的行动:

//...

export function putImage(props) {

  console.log(props)

  const cloudinaryURL = 'https://api.cloudinary.com/v1_1/<my_name_here>/image/upload';

  const image =
    axios.post(cloudinaryURL, {
      file: props,
      upload_preset: 'test123'
    })
    .then(function(response) {
      console.log(response)
    })
    .catch(function(error) {
      console.log(error)
    })

  return {
    type: PUT_IMAGE,
    payload: image,
  }
}
/。。。
导出函数图像(道具){
控制台日志(道具)
const cloudinaryURL='1〕https://api.cloudinary.com/v1_1//image/upload';
常量图像=
axios.post(cloudinaryURL{
文件:道具,
上传预设:“test123”
})
.然后(功能(响应){
console.log(响应)
})
.catch(函数(错误){
console.log(错误)
})
返回{
类型:PUT_图像,
有效载荷:图像,
}
}

我通过Redux表单正确处理了这个文件输入/jpg上传吗?非常感谢您的任何帮助。谢谢

我对axios也有同样的问题,但找不到关于这个问题的任何答案,然后我切换到superagent,它工作正常


我对axios也有同样的问题,并且找不到任何关于这个问题的答案,然后我切换到superagent,它工作正常


你成功了吗?你成功了吗?
  import request from 'superagent';

  let upload = request.post(CLOUDINARY.UPLOAD_URL)
    .field('upload_preset', CLOUDINARY.UPLOAD_PRESET)
    .field('file', file); // file to upload

  upload.end((err, response) => {
    if (err) {
      console.error(err); // error handling
    }

    if (response.body.secure_url !== '') {
      console.log(response.body.secure_url); // cloudinary image url
    }
  });