FileSystemManager.copyFile
收藏我的收藏
基础库 1.15.0 开始支持本方法,这是一个异步方法。
复制文件。
前提条件 | 无 |
业务背景 | 无 |
使用限制 | 无 |
注意事项 |
|
相关教程 | 无 |
语法
FileSystemManager.copyFile(options)
参数说明
options 为 object 类型,属性如下:
属性名 | 类型 | 默认值 | 必填 | 说明 | 最低支持版本 |
---|---|---|---|---|---|
srcPath | string | 是 | 源文件路径,只可以是普通文件,不能是目录 | 1.15.0 | |
destPath | string | 是 | 目标文件路径, 必须以 ttfile://user 开头 | 1.15.0 | |
success | function | 否 | 接口调用成功的回调函数 | 1.15.0 | |
fail | function | 否 | 接口调用失败的回调函数 | 1.15.0 | |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失 败都会执行) | 1.15.0 |
回调成功
object 类型,属性如下:
属性名 | 类型 | 说明 | 最低支持版本 |
---|---|---|---|
errMsg | string | "FileSystemManager.copyFile:ok" | 1.15.0 |
回调失败
object 类型,属性如下:
属性名 | 类型 | 说明 | 最低支持版本 |
---|---|---|---|
errMsg | string | "FileSystemManager.copyFile:fail" + 详细错误信息 | 1.15.0 |
错误码
errNo | errMsg | 说明 | 最低支持版本 |
---|---|---|---|
10401 | error stack | 小游戏框架内部错误,有需要请创建工单咨询 | 1.15.0 |
21101 | permission denied, $apiName $srcPath -> $destPath | 1.15.0 | |
21102 | operation not permitted, $apiName $srcPath | 1.15.0 | |
21103 | no such file or directory, $apiName $srcPath -> $destPath | 1.15.0 | |
21104 | user dir saved file size limit exceeded | 1.15.0 | |
20001 | invalid param | 参数错误 | 1.15.0 |
20000 | params $paramName is required | 1.15.0 | |
20000 | params $paramName type is not $paramType type | 1.15.0 | |
20000 | $paramName is invalid | 1.15.0 | |
20000 | no such file or directory, $apiName $filePath | 1.15.0 | |
21105 | operation failed | 小游戏框架内部错误,有需要请创建工单咨询 | 1.15.0 |
20000 | internal error | 小游戏框架内部错误,有需要请创建工单咨询 | 1.15.0 |
代码示例
const fileSystemManager = tt.getFileSystemManager(); tt.chooseImage({ success(res) { copyFile(res.tempFilepaths[0], `ttfile://user/my-pic`); }, fail(res) { console.log("下载失败", res.errMsg); }, }); function copyFile(srcPath, destPath) { fileSystemManager.copyFile({ srcPath, destPath, success(_res) { console.log("拷贝成功"); }, fail(res) { console.log("拷贝失败", res.errMsg); }, }); }