当前位置:网站首页>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)
}
})
边栏推荐
- C language pointer (exercises)
- flinkcdc 用sqlclient可以指定mysqlbinlog id执行任务吗
- Detailed learning notes of JVM memory structure (I)
- Pytest+request+allure+excel interface automatic construction from 0 to 1 [five nails / flying Book notice]
- Leetcode daily questions (2316. count unreachable pairs of nodes in an undirected graph)
- Regular matching starts with XXX and ends with XXX
- [SVN] what is SVN? How do you use it?
- Data association between two interfaces of postman
- 信息安全实验二 :使用X-SCANNER扫描工具
- Cesium does not support 4490 problem solution and cesium modified source code packaging scheme
猜你喜欢
随机推荐
Confitest of fixture py
Information Security Experiment 2: using x-scanner scanning tool
Postman interface test (II. Set global variables \ sets)
Do you have any certificates with high gold content?
牛客网——华为题库(61~70)
其实特简单,教你轻松实现酷炫的数据可视化大屏
網易雲微信小程序
PMP Exam details after the release of the new exam outline
PMP certificate preparation experience sharing
Dynamics 365Online ApplicationUser创建方式变更
(3/8) method parameters of improper use of enumeration (2)
4、 Fundamentals of machine learning
JMeter JDBC batch references data as input parameters (the simplest method for the whole website)
Connecting mobile phone with ADB
Unity shader (learn more about vertex fragment shaders)
Leetcode daily questions (2316. count unreachable pairs of nodes in an undirected graph)
esp8266使用TF卡并读写数据(基于arduino)
VSCode+mingw64+cmake
Pytest installation (command line installation)
ComputeShader








