当前位置:网站首页>Upload taro pictures to Base64
Upload taro pictures to Base64
2022-07-07 09:27:00 【-Coffee-】
It hasn't been updated for a long time csdn 了 , Shake yourself up , Keep updating taro The pit on the road of learning ....
Recently used taro Develop multi terminal applet , Front end and back end data interaction , Stepped on a lot of pits , because taro Relatively new , So many problems are difficult to find solutions from the Internet ,
now, recorded , Share with friends in need .
Cut to the chase :
The original idea of the picture is to base64 Back end processing , But look at the document Decide to use uploadFile Upload to the third-party cloud image server , Encounter various problems , Failed to succeed , Calm down and , Original intention of detection , turn base64, Back end to handle , The code is as follows
// The picture is translated into base64
imgOnChange (files) {
this.setState({
files
})
Taro.request({
url:files[0].url,
responseType: 'arraybuffer', // The most critical parameter , Set the returned data format to arraybuffer
success:res=>{
// hold arraybuffer Turn into base64
let base64 = Taro.arrayBufferToBase64(res.data);
// Without this string of characters , Cannot display
base64 = 'data:image/jpeg;base64,' + base64
// see base64 character string , You can also go to the web page to check whether it can be restored to your picture
console.log(base64)
}
})
边栏推荐
- Unity shader (to achieve a simple material effect with adjustable color attributes only)
- 其实特简单,教你轻松实现酷炫的数据可视化大屏
- Postman data driven
- Interface test API case, data and interface separation
- Do you have any certificates with high gold content?
- Entity of cesium data visualization (Part 1)
- Final keyword
- Detailed learning notes of JVM memory structure (I)
- Jenkins automated email
- Cesium load vector data
猜你喜欢

华为HCIP-DATACOM-Core_03day

Storage of data in memory

十二、排序

信息安全实验四:Ip包监视程序实现

Cesium does not support 4490 problem solution and cesium modified source code packaging scheme

Mysql database transaction learning notes

NATAPP内网穿透

战略合作|SubQuery 成为章鱼网络浏览器的秘密武器

Postman interface test (II. Set global variables \ sets)

Oracle安装增强功能出错
随机推荐
Postman data driven
Nested (multi-level) childrn routes, query parameters, named routes, replace attribute, props configuration of routes, params parameters of routes
Mysql数据库-锁-学习笔记
How to speed up video playback in browser
Information Security Experiment 4: implementation of IP packet monitoring program
Jenkins automated email
牛客网——华为题库(61~70)
Error: selenium common. exceptions. WebDriverException: Messag‘geckodriver‘ execute
Using JWT to realize login function
SiteMesh getting started example
H5网页播放器EasyPlayer.js如何实现直播视频实时录像?
Over 100000 words_ Ultra detailed SSM integration practice_ Manually implement permission management
Connecting mobile phone with ADB
Unity uses mesh to realize real-time point cloud (II)
Sublime Text4 download the view in bower and set the shortcut key
章鱼未来之星获得25万美金奖励|章鱼加速器2022夏季创业营圆满落幕
4、 Fundamentals of machine learning
Mysql database index study notes
C language pointer (special article)
Difference between interface iterator and iteratable