解释:将资源文件从云存储空间下载至本地。

参数说明
该方法的传入参数类型为对象类型,参数说明如下:
| 字段 | 类型 | 必填 | 说明 | 
|---|---|---|---|
| fileID | String | 是 | 云文件 ID | 
| config | Object | 否 | 局部覆盖 swan.cloud.init 中的全局配置 | 
| success | Function | 否 | 接口调用成功的回调函数 | 
| fail | Function | 否 | 接口调用失败的回调函数 | 
| complete | Function | 否 | 接口调用结束的回调函数 | 
config参数说明:
| 字段 | 类型 | 说明 | 
|---|---|---|
| env | String | 使用的环境 ID,将覆盖 swan.cloud.init 指定的环境 | 
success返回参数说明
| 字段 | 类型 | 说明 | 
|---|---|---|
| tempFilePath | String | 临时文件路径 | 
| statusCode | Number | 服务器返回的 HTTP 状态码 | 
| errMsg | String | 调用成功的信息 | 
fail返回参数说明
| 字段 | 类型 | 说明 | 
|---|---|---|
| errCode | Number | 错误码 | 
| errMsg | String | 错误信息 | 
代码示例
callback风格:
swan.cloud.downloadFile({fileID: 'test-env/my-image.png',success: res => {console.log(res.tempFilePath)},fail: err => {// ...}});
Promise风格:
swan.cloud.downloadFile({fileID: 'test-env/my-image.png'}).then(res => {console.log(res.tempFilePath)}).catch(err => {// ...});
                当前文章:创新互联百度小程序教程:swan.cloud.downloadFile
                
                路径分享:http://www.csdahua.cn/qtweb/news7/391807.html
            
网站建设、网络推广公司-快上网,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 快上网