找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索本站精品资源

首页 教程频道 小程序开发 查看内容

微信小程序1028版本新增:文件管理 API说明

作者:模板之家 2020-10-12 18:41 2280人关注

微信,小,程序,1028,版本,新增,文件,管理,API," name=keywords>

wx.saveFile(OBJECT)保存文件到本地。OBJECT参数说明:参数类型必填说明tempFilePathString是需要保存的文件的临时路径successFunction否返回文件的保存路径,res = {savedFilePath: '文件的保存路径'}failFunction ...

 
 
 

wx.saveFile(OBJECT)

保存文件到本地。
OBJECT参数说明:
[tr]参数类型必填说明[/tr]

 

tempFilePath String 需要保存的文件的临时路径
success Function 返回文件的保存路径,res = {savedFilePath: '文件的保存路径'}
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

示例代码:

1
2
3
4
5
6
7
8
9
10
wx.startRecord({
    success: function(res) {
        var tempFilePath = res.tempFilePath wx.saveFile({
            tempFilePath: tempFilePath,
            success: function(res) {
                var savedFilePath = res.savedFilePath
            }
        })
    }
}) wx.getSavedFileList(OBJECT)

 



获取本地已保存的文件列表
OBJECT参数说明:
[tr]参数类型必填说明[/tr]

success Function 接口调用成功的回调函数,返回结果见success返回参数说明
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

success返回参数说明:
[tr]参数类型说明[/tr]

errMsg String 接口调用结果
fileList Object Array 文件列表

fileList中的项目说明:
[tr]键类型说明[/tr]

filePath String 文件的本地路径
createTime Number 文件的保存时的时间戳,从1970/01/01 08:00:00 到当前时间的秒数
size Number 文件大小,单位B

示例代码:

1
2
3
4
5
wx.getSavedFileList({
    success: function(res) {
        console.log(res.fileList)
    }
}) wx.getSavedFileInfo(OBJECT)

 

复制代码
获取本地文件的文件信息
OBJECT参数说明:
[tr]参数类型必填说明[/tr]

filePath String 文件路径
success Function 接口调用成功的回调函数,返回结果见success返回参数说明
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

success返回参数说明:
[tr]参数类型说明[/tr]

errMsg String 接口调用结果
size Number 文件大小,单位B
createTime Number 文件的保存是的时间戳,从1970/01/01 08:00:00 到当前时间的秒数

示例代码:

1
2
3
4
5
6
7
wx.getSavedFileInfo({
    

路过

雷人

握手

鲜花

鸡蛋
原作者: 模板之家 来自: 网络收集

全部回复(0)