我想从我的应用程序上载图像到S3服务器。我已经计算了所有的数据和代码(在计算机上使用curl进行了测试),但是我不知道如何正确地调用'fetch‘。我得到的回应是:
‘您指定的前提条件中至少有一个不成立。条件:存储桶POST的类型必须为enclosure-type-multipart/form-data’
如何在react-natives中重新创建表单数据?没有像fetches示例中那样可以追加然后发送的FormData。
编辑:谢谢@philipp-von-weitershausen,非常感谢你添加了这个功能。然而,我在调用它时遇到了一些麻烦。我得到了“不支持的BodyInit类型”。发现这是因为在fetch.js中:"support.formData“返回false。当我调用fetch时,我遗漏了什么?
我的代码示例:
 var form = new FormData();
 form.append("FormData", true)
 form.append("name", this.state.invoiceNumber)
 form.append("key", this.state.invoiceNumber)
 form.append("Content-Type", "image/png")
 form.append('file', this.props.uri)
 //alert(FormData.prototype.isPrototypeOf(form))
  fetch(amazon_url,{body: form,mode: "FormData", method: "post", headers: {"Content-Type": "multipart/FormData"}})
          .then((response) => response.json())
          .catch((error) => {
             alert("ERROR " + error)
          })
          .then((responseData) => {
             alert("Succes "+ responseData)
          })
          .done();https://stackoverflow.com/questions/30737226
复制相似问题