当前位置:网站首页>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
边栏推荐
- 代理IP可用率是不是等同于代理IP的效率?
- Multithreading technology core
- Analyze the three functions of static proxy IP.
- [Dahua cloud native] micro service chapter - service mode of five-star hotels
- 2018 China Collegiate Programming Contest - Guilin Site J. stone game
- What is an API interface?
- 使用代理IP是需要注意什么?
- 一加一为什么等于二
- [Leetcode每日一题]396. 旋转函数
- How to call out services in idea and display the startup class in services
猜你喜欢
拨号vps会遇到什么问题?
一加一为什么等于二
What business scenarios will the BGP server be used in?
搭建个人主页保姆级教程(二)
Talk about biology live broadcast: Dr. Wang Ziyuan, a lake view biology, exploring hepatitis B with gene therapy
010_StringRedisTemplate
Easyswool environment configuration
89 logistic回歸用戶畫像用戶響應度預測
使用代理IP是需要注意什么?
有哪些业务会用到物理服务器?
随机推荐
How to choose a good dial-up server?
What problems will you encounter when dialing VPS?
动态代理ip的测试步骤有哪些?
postman里面使用 xdebug 断点调试
Is the availability of proxy IP equal to the efficiency of proxy IP?
Is the sinking coffee industry a false prosperity or the eve of a broken situation?
PID refinement
不断下沉的咖啡业,是虚假的繁荣还是破局的前夜?
Open3d point cloud processing
有哪些业务会用到物理服务器?
想体验HomeKit智能家居?不如来看看这款智能生态
[assembly language] understand "stack" from the lowest point of view
leetcode:27. Remove element [count remove]
002_Redis_String类型常见的操作命令
PHP & laravel & master several ways of generating token by API and some precautions (PIT)
Introduction to micro build low code zero Foundation (lesson 2)
What is an API interface?
Unicorn bio raised $3.2 million to turn prototype equipment used to grow meat into commercial products
【汇编语言】从最底层的角度理解“堆栈”
Campus transfer second-hand market source code