Closed johnbryant closed 7 years ago
这是formInput里的内容。
是的,我也遇到这个问题了,请问你解决了吗
@CecilLee 试一下新的版本 3.0
@buhe xhr也是不可以的,400错误一定会有。
但也不能确定是0.39.2的问题,
400错误是服务端报告的吧
这个问题应该是qiniu的服务端的问题
未必是服务器问题,是 payload 的问题,这个问题我们定位过了,0.39 有一定几率发送错误的 payload
@buhe 表示用了3.0上传没成功过,一直报这个错
还是用的2.0版本,上传之前把图片压缩了一下,就很少出问题了
我是 0.40,大概率遇到 400 错误,偶尔 200 ok
应该是 React Native xhr API 的问题,更换为 react-native-fetch-blob 后问题解决。
import Qiniu from 'react-native-qiniu';
import RNFetchBlob from 'react-native-fetch-blob';
/**
* Use react-native-fetch-blob to fix large file issue
*/
export function uploadFile(uri, token, formInput) {
if (typeof formInput.type == 'undefined') {
formInput.type = 'application/octet-stream';
}
if (typeof formInput.name == 'undefined') {
var filePath = uri.split("/");
if (filePath.length > 0) {
formInput.name = filePath[filePath.length - 1];
} else {
formInput.name = "";
}
}
return RNFetchBlob.fetch('POST', Qiniu.Conf.UP_HOST, {
'Content-Type' : 'multipart/form-data',
}, [
{ name: 'file', filename: formInput.name, type: formInput.type, data: RNFetchBlob.wrap(uri)},
{ name : 'key', data : formInput.key},
{ name : 'token', data : token},
]);
}
@johnbryant 上传之前把图片压缩 在rn里面用了什么组件 压缩的?
你们 使用七牛 rn版本 上传图片速率是多少?
@jlala react-native-image-resizer
up是不准备更新这个bug了吗?最佳解决方案是什么? @buhe
rn版本:0.39.2