【发布时间】:2021-11-29 12:09:16
【问题描述】:
通过选择图像或文件库我的数据看起来像这样
[{"fileCopyUri": "content://com.android.providers.media.documents/document/image%3A55539", "name": "c6235fa2-aa7f-4e06-a664-7e805de2f883.jpg", "大小”:1967925,“类型”: "image/jpeg", "uri": "content://com.android.providers.media.documents/document/image%3A55539"}]
{"fileCopyUri": "content://com.android.providers.media.documents/document/document%3A55435", "name": "Maha Police-2019 222.pdf", "size": 302194, “类型”:“应用程序/pdf”,“uri”:“内容://com.android.providers.media.documents/document/document%3A55435”}
通过从相机捕获图像我的数据看起来像这样
{“assets”:[{“fileName”:“rn_image_picker_lib_temp_c96a3333-f53f-4143-af29-e0270c8e6a8c.jpg”,“fileSize”:24925,“height”:550,“type”:“image/jpeg”, "uri": "file:///data/user/0/com.sanayaapp/cache/rn_image_picker_lib_temp_c96a3333-f53f-4143-af29-e0270c8e6a8c.jpg", "width": 247}]}
我正在像这样通过 FormData 发送数据
const formData = new FormData();
formData.append('SellerBrandsWeDeal', selectedFile);
fetch('http://api', {
method: 'POST',
headers: {Accept: '*/*', 'Content-Type': 'multipart/form-data'},
body: formData,
})
但它一直说网络错误。请帮忙谢谢
【问题讨论】:
标签: javascript react-native file-upload multipartform-data form-data