当前位置:网站首页>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)
}
})
边栏推荐
- LeetCode每日一题(2316. Count Unreachable Pairs of Nodes in an Undirected Graph)
- Do you have any certificates with high gold content?
- Pytest+request+allure+excel interface automatic construction from 0 to 1 [five nails / flying Book notice]
- STM32 and motor development (from stand-alone version to Networking)
- Regular matching starts with XXX and ends with XXX
- Skill review of test engineer before interview
- Information Security Experiment 4: implementation of IP packet monitoring program
- Pycharm create a new file and add author information
- C language pointer (Part 2)
- 超十万字_超详细SSM整合实践_手动实现权限管理
猜你喜欢

Install pyqt5 and Matplotlib module

Information Security Experiment 1: implementation of DES encryption algorithm

How to pass the PMP Exam in a short time?

信息安全实验一:DES加密算法的实现

12、 Sort

Integer or int? How to select data types for entity classes in ORM
![[cloud native] Devops (I): introduction to Devops and use of code tool](/img/e0/6152b3248ce19d0dbba3ac4845eb65.png)
[cloud native] Devops (I): introduction to Devops and use of code tool

Using JWT to realize login function

Data association between two interfaces of postman

Postman interface test (II. Set global variables \ sets)
随机推荐
[cloud native] Devops (I): introduction to Devops and use of code tool
章鱼未来之星获得25万美金奖励|章鱼加速器2022夏季创业营圆满落幕
答案在哪里?action config/Interceptor/class/servlet
【云原生】DevOps(一):DevOps介绍及Code工具使用
ComputeShader
Jemter operation
Record of structured interview
Jenkins+ant+jmeter use
JVM 内存结构 详细学习笔记(一)
NATAPP内网穿透
Network request process
(3/8) method parameters of improper use of enumeration (2)
Test Engineer Interview Questions 2022
SiteMesh getting started example
C language pointer (special article)
Oracle安装增强功能出错
Pytest installation (command line installation)
四、机器学习基础
Regularly modify the system time of the computer
Skill review of test engineer before interview