jeh*_*hoi 4 reactjs react-native
我找到了一些库,但我不确定哪一个适合我并且稳定。
我正在使用表单数据实现类似电子邮件附件的功能。
选择从图库上传文件或 Android 设备上的文件管理并上传到服务器。
你能推荐一些不错的图书馆吗?谢谢 !
我发现了什么
https://github.com/kaancelen/react-native-nononsense-file-picker
https://github.com/Elyx0/react-native-document-picker
https://github.com/farmisen/react-native-file-uploader
https://github.com/huangzuizui/react-native-file-opener
等等..
您需要首先使用文档选择器 - 使用
react-native-document-picker
https://github.com/Elyx0/react-native-document-picker
然后在文档选择器的回调中创建一个表单数据对象
data = new FormData();
data.append('resource', {
name: res.fileName,
uri: res.uri, type: res.type
});
Run Code Online (Sandbox Code Playgroud)
var req = {
method: "POST",
headers: {
'Auth-Identifier': access_token,
},
body:file
}
Run Code Online (Sandbox Code Playgroud)
在您的 fetch 调用中使用上述请求。它会对你有用。
| 归档时间: |
|
| 查看次数: |
18990 次 |
| 最近记录: |