如何使用Node.js将Redux格式的图片上传到AWS S3

时间:2019-02-19 18:22:09

标签: javascript node.js reactjs react-redux redux-form

这不是重复的问题

我正在尝试使用nodejs将图像上传到AWS s3,这是我的 redux格式

  const onSubmit = (image, dispatch)=>
  {        
    dispatch(imageActions.LogoUpdate(image)) ;  
  }


  const ImageEditPageForm = ({ handleSubmit }) => {
    return (    
     <form onSubmit={handleSubmit(onSubmit)}>
        <Field label="logo" name="logo" component={customFileInput}  type="file" />   
        <button type="submit" label="submit">Submit</button>
      </form>

    );
  }

服务代码

function LogoUpdate(image) {
    const requestOptions = {
        method: 'PUT',
        headers: { ...authHeader(), 'Content-Type': 'multipart/form-data' },
        body: JSON.stringify(image)
    };
    console.log(image);
    return fetch(`${apiUrl}/logo/${image.parentId}`, requestOptions).then(handleResponse)
    .then( data => {  return data; });
}

卡在nodejs上。未接收任何数据,这是我从客户端

发出的 image 控制台日志
{id: "5c66478b0814720a4365fe72", parentId: "5c66478b0814720a4365fe71", editing: true, logo: FileList}
editing: true
id: "5c66478b0814720a4365fe72"
logo: FileList
0: File(19355) {name: "11964821.jpeg", lastModified: 1549777663435, lastModifiedDate: Sun Feb 10 2019 11:17:43 GMT+0530 (India Standard Time), webkitRelativePath: "", size: 19355, …}
length: 1
__proto__: FileList
parentId: "5c66478b0814720a4365fe71"

0 个答案:

没有答案