当前位置:网站首页>Applet reads files
Applet reads files
2022-04-23 02:07:00 【Yixi Muze】
order : Because the applet cannot directly read the contents of the file under the package , So put the file on the server , Use download to get files to applet , Get the temporary file address , And read the contents of the file
The applet reads the contents of the file
getFileData(){
let that = this;
const fs = wx.getFileSystemManager()
let url = app.globalData.domain; // Request domain name path
// Download the file responded by the server to the temporary file , Read the contents of the file as needed
wx.downloadFile({
url: url +'/api/otaNewFile', // download ota.hex file
success (res) {
if (res.statusCode === 200) {
// Method 1 : Read file information
fs.readFile({
filePath: res.tempFilePath, // Get the temporary or local file path
encoding: 'hex',
success(resd) {
that.setData({
otaData: resd.data
})
console.log(" Read file information :",resd)
},
})
// Method 2 : Read file information
// let arrBuffer = fs.readFileSync(res.tempFilePath,'hex')
// console.log(" Read file information :",arrBuffer)
}
}
})
},
Looking forward to the follow-up ...
版权声明
本文为[Yixi Muze]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230207164891.html
边栏推荐
- [assembly language] understand "stack" from the lowest point of view
- Is CICC fortune a company with CICC? Is it safe
- What is a dial-up server and what is its use?
- Lane cross domain problem
- Find the largest number of two-dimensional arrays
- What problems will you encounter when dialing VPS?
- 浅析一下隧道代理IP的优缺点。
- 【dpdk】10. Dpdk DNS learning notes
- Realize linear regression with tensorflow (including problems and solutions in the process)
- 用TensorFlow实现线性回归(包括过程中出现的问题及解决方法)
猜你喜欢

Wechat public platform test number application, authorized login function and single sign on using hbuilder X and wechat developer tools

用TensorFlow实现线性回归(包括过程中出现的问题及解决方法)

013_基于Session实现短信验证码登录流程分析

How to set computer IP?

Virtual serial port function of j-link V9 using skills

Redis memory recycling strategy

Open3d point cloud processing

【dpdk】10. Dpdk DNS learning notes

什么是api接口?

What is a dial-up server and what is its use?
随机推荐
Use Xdebug breakpoint debugging in postman
【ValueError: math domain error】
不断下沉的咖啡业,是虚假的繁荣还是破局的前夜?
002_Redis_String类型常见的操作命令
一加一为什么等于二
How to configure iptables to realize local port forwarding
Consider defining a bean of type ‘com.netflix.discovery.AbstractDiscoveryClientOptionalArgs‘
【Chrome扩展程序】content_script的跨域问题
动态代理ip的测试步骤有哪些?
C standard library - < time h>
Is it better to use a physical machine or a virtual machine to build a website?
配置iptables实现本地端口转发的方法详解
Makefile文件是什麼?
如何设置电脑ip?
都是做全屋智能的,Aqara和HomeKit到底有什么不同?
EBS:PO_EMPLOYEE_HIERARCHIES_ALL
Introduction to micro build low code zero Foundation (lesson 2)
013_基于Session实现短信验证码登录流程分析
拨号服务器是什么,有什么用处?
Implementation of Base64 encoding / decoding in C language