当前位置:网站首页>微信小程序7-云存储
微信小程序7-云存储
2022-07-17 22:28:00 【k55】
微信小程序1-小程序基础,开发工具安装使用
微信小程序2-WXSS,WXS
微信小程序3-小程序生命周期和组件
微信小程序4-小程序的api
微信小程序5-真机测试
微信小程序6-云开发-云数据库
1.云存储
云开发提供了一块存储空间,提供了上传文件到云端、带权限管理的云端下载能力,开发者可以在小程序端和云函数端通过 API 使用云存储功能。
1).上传图片
// 让用户选择一张图片
wx.chooseImage({
success: chooseResult => {
// 将图片上传至云存储空间
wx.cloud.uploadFile({
// 指定上传到的云路径
cloudPath: 'my-photo.png',
// 指定要上传的文件的小程序临时文件路径
filePath: chooseResult.tempFilePaths[0],
// 成功回调
success: res => {
console.log('上传成功', res)
},
})
},
})



2).下载图片
wx.cloud.downloadFile({
// 文件 ID
fileID: 'cloud://cloud1-2gdjrvddfc6ce99e.636c-cloud1-2gdjrvddfc6ce99e-1312827414/my-photo.png',
success: res => {
// 返回临时文件路径
console.log(res.tempFilePath)
},
fail: console.error
})


3).删除文件
wx.cloud.deleteFile({
//填的file ID
fileList: ['cloud://cloud1-2gdjrvddfc6ce99e.636c-cloud1-2gdjrvddfc6ce99e-1312827414/my-photo.png'],
success: res => {
// handle success
console.log(res.fileList)
},
fail: console.error
})

边栏推荐
猜你喜欢

Authing practice | unified management solution for manufacturing identity authentication

BigScience 开源 Bloom 的自然语言处理模型

kube-proxy & Service & Endpoint

Single channel 6Gsps 12 bit AD acquisition and single channel 6Gsps 16 bit Da (ad9176) output sub card based on vita57.1 standard

Leetcode 1296. 划分数组为连续数字的集合(已解决)

High performance pxie data preprocessing board based on kinex ultrascale series FPGA (ku060 +fmc sub card interface)

Comparaison de deux types de machines virtuelles

通过授权微信,达到软件登录账号的效果~~未完

Cilium & Hubble

csrf防护机制
随机推荐
MySQL storage functions and triggers
Zabbix实现对Redis的监控
天勤第九章课后习题代码
Classes abstraites et dérivées
06_服务调用Feign
1、DBMS基本概念
SBOM(Software Bill of Materials,软件物料清单)
Chapter 1 preliminary knowledge
国科大.深度学习.期末复习知识点总结笔记
见鬼,U盘空间怎么少了,原来是EFI分区搞的鬼,删除它
Which company is better in data filling and report presentation? Yixin ABI gives you the answer
Maximum heap and heap sort and priority queue
长安链学习研究-存储分析wal机制
中断的分类
Cilium & Hubble
08_服务熔断Hystrix
[Axi] interpret the additional signals of the Axi protocol (QoS signal, region signal, and user signal)
Google Earth engine - Classification and processing of UAV images
Summary of the third week of summer vacation
dba