React Native使用fetch实现图片上传
来源:互联网 发布:最后免费升级windows 编辑:程序博客网 时间:2024/05/14 06:17
关于 React Native 网络请求的封装,可以参考我写的文章:http://blog.csdn.net/withings/article/details/71363433
React Native 网络请求封装:使用Promise封装fetch请求
普通网络请求参数是JSON对象
图片上传的请求参数使用的是formData对象
fetch实现图片上传代码如下:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
使用方法
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
注意:由于后台服务器配置的不同, let file = {uri: params.path, type: 'application/octet-stream', name: 'image.jpg'}
中的type
也可能是multipart/form-data
formData.append("file", file)
中的的file
字段也可能是images
阅读全文
0 0
- React Native使用fetch实现图片上传
- React Native使用fetch实现图片上传
- React Native 使用react-native-image-picker库实现图片上传功能
- React-Native之fetch的使用
- React-Native Fetch使用Promise封装(一)
- 《React-Native系列》26、 ReactNative实现图片上传功能
- 《React-Native系列》26、 ReactNative实现图片上传功能
- 使用react-native-image-crop-picker上传图片
- react native fetch 用法
- react native fetch
- React Native 使用react-native-image-picker插件上传图片详细步骤
- react-native 实现上传功能
- react-native实现文件上传
- React Native 网络请求封装:使用Promise封装fetch请求
- React Native 网络请求封装:使用Promise封装fetch请求
- React Native 网络请求封装:使用Promise封装fetch请求
- React Native探索(五)使用fetch进行网络请求
- React Native 网络请求封装:使用Promise封装fetch请求
- linux无损调整分区大小
- 面向对象编程
- 设计模式之观察者模式
- c/c++中extern关键字的编译原理和使用
- LeetCode135 Candy
- React Native使用fetch实现图片上传
- 【Effection C++】读书笔记 条款05~条款06
- 1112. Stucked Keyboard (20)[字符串处理]
- LeetCode136 Single Number
- OnTouchEvent方法实现View的拖动效果
- 高级I/O函数
- Oracle 数据库基础练习②
- React Native 网络请求封装:使用Promise封装fetch请求
- 九宫格输入法