codecamp

微信小游戏开发文档-小游戏文件API FileSystemManager.saveFile(Object object)

FileSystemManager.saveFile(Object object)

保存临时文件到本地。此接口会移动临时文件,因此调用成功后,tempFilePath 将不可用。

参数

Object object
属性 类型 默认值 是否必填 说明 支持版本
tempFilePath string 是 临时存储文件路径
filePath string 是 要存储的文件路径
success function 否 接口调用成功的回调函数
fail function 否 接口调用失败的回调函数
complete function 否 接口调用结束的回调函数(调用成功、失败都会执行)

success 回调函数

参数
Object res
属性 类型 说明 支持版本
savedFilePath number 存储后的文件路径

fail 回调函数

参数
Object res
属性 类型 说明 支持版本
errMsg string 错误信息

res.errMsg 的合法值

值 说明
fail tempFilePath file not exist 指定的 tempFilePath 找不到文件
fail permission denied, open "${filePath}" 指定的 filePath 路径没有写权限
fail no such file or directory "${dirPath}" 上级目录不存在
微信小游戏开发文档-小游戏文件API string FileSystemManager.rmdirSync(Object filePath)
微信小游戏开发文档-小游戏文件API FileSystemManager.stat(Object object)
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

微信小游戏 API

微信小游戏API 系统

微信小游戏设备

微信小游戏API 文件

微信小游戏网络

微信小游戏API 界面

微信小游戏数据上报

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }