使用 React dropzone,我已经使用onDrop回调成功访问了图像。但是,我尝试通过将图像发送到我的服务器、保存到 S3 存储桶并将图像的签名 URL 返回给客户端来上传到 Amazon S3。
到目前为止,我无法使用我所拥有的信息来做到这一点,而且据我所知,文档似乎没有提到这一点。
onDrop 使用文件在我的 redux 操作中触发函数调用:
export function saveImageToS3 (files, user) {
  file = files[0]
  // file.name -> filename.png
  // file -> the entire file object
  // filepreview -> blob:http:localhost:3000/1ds3-sdfw2-23as2
  return {
    [CALL_API] : {
      method:'post',
      path: '/api/image',
      successType: A.SAVE_IMAGE,
      body: {
        name: file.name,
        file: file,
        preview: file.preview,
        username: user
      }
    }
  }
}
但是,当我到达我的服务器时,我不确定如何保存这个 blob 图像(仅从浏览器中引用。)
 server.post('/api/image', (req, res) => {
  // req.body.preview --> blob:http://localhost:3000/1ds3-sdfw2-23as2
  // req.body.file -> {preview:blob:http://localhost:3000/1ds3-sdfw2-23as2}, no other properties for some reason
})